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
|
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)
STATUS = (
(0, 'Call In'),
(1, 'Coming'),
(2, 'Testing'),
(3, 'Done'),
(4, 'Live'),
)
status = models.IntegerField(choices=STATUS, default=0)
class Meta:
ordering = ('date_created',)
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()
|