]> git.p6c8.net - pcdenotes.git/blob - notes/models.py
Removed needless double quote
[pcdenotes.git] / notes / models.py
1 from django.db import models
2 from django.contrib.auth.models import User
3 from django.urls import reverse
4
5 # Create your models here.
6
7 NOTE_STATUS = ((0, "Draft"),
8 (1, "Published"))
9
10 class Note(models.Model):
11 title = models.CharField(max_length=250)
12 slug = models.SlugField(max_length=250, unique=True)
13 author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='notes_posted')
14 content = models.TextField()
15 status = models.IntegerField(choices=NOTE_STATUS, default=0)
16
17 created_at = models.DateTimeField(auto_now_add=True)
18 updated_at = models.DateTimeField(auto_now=True)
19
20 class Meta:
21 ordering = ['-created_at']
22
23 def __str__(self):
24 return self.title
25
26 def get_absolute_url(self):
27 return reverse("notes:note_detail", kwargs={"note_slug": self.slug})
28 #return "/notes/%s" % (self.slug)
29
30 def is_draft(self):
31 return self.status == 0
32
33 def is_published(self):
34 return self.status == 1

patrick-canterino.de