from django.db import models from django.urls import reverse from django.utils.html import format_html, format_html_join from django.utils import timezone import settings from posts.models import Post class Note(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL) title = models.CharField(max_length=400) url = models.CharField(max_length=400, blank=True, null=True) body_markdown = models.TextField(blank=True, null=True) date_created = models.DateTimeField(default=timezone.now) post = models.ForeignKey(Post, on_delete=models.CASCADE, null=True, blank=True) STATUS = ( (0, 'Call In'), (1, 'Asked For'), (2, 'Coming'), (3, 'Testing'), (4, 'Done'), (5, 'Live'), ) status = models.IntegerField(choices=STATUS, default=0) PLAN = ( (0, 'For Guide'), (1, 'Review'), (2, 'Rave/Rant'), (3, 'No Plan'), ) plan = models.IntegerField(choices=PLAN, default=0) class Meta: ordering = ('date_created', 'status') def __str__(self): return self.title def get_absolute_url(self): return reverse('notes:edit', kwargs={"pk": self.pk}) def save(self, *args, **kwargs): super(Note, self).save()