1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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()
|