]> gitweb.fperrin.net Git - djsite.git/blob - quotes/models.py
Use django-tagging for tags
[djsite.git] / quotes / models.py
1 from django.db import models
2 from localmodels import HTMLField, TagField
3
4 # Create your models here.
5 class Author(models.Model):
6     name = models.CharField(max_length=100,
7                             help_text="Name of the author")
8     notes = HTMLField(blank=True, help_text= \
9                       "Notes about the author; may be left blank. Will \
10                       not be HTML-escaped.",)
11     pvt_notes = HTMLField(blank=True, help_text= \
12                           "Notes about the author; not displayed on \
13                           the public interface",)
14     tags = TagField()
15
16     birth_date = models.DateField(blank=True, null=True,
17                                   help_text="Date of birth")
18     death_date = models.DateField(blank=True, null=True,
19                                   help_text="Date of death (leave blank \
20                                   if still alive!)")
21
22     def __str__(self):
23         return self.name
24
25 # class DatePrecision(models.CharField):
26 #     DAY = "D"
27 #     MONTH = "M"
28 #     YEAR = "Y"
29 #     DECADE = "X"
30 #     CENTURY = "C"
31 #     UNKNOWN = "?"
32 #     PRECISION_CHOICES = [
33 #         (DAY, "Day"),
34 #         (MONTH, "Month"),
35 #         (YEAR, "Year"),
36 #         (DECADE, "Decade"),
37 #         (CENTURY, "Century"),
38 #         (UNKNOWN, "Unknown"),
39 #     ]
40 #     def __init__(self, **kwargs):
41 #         models.CharField(max_length=1, choices=self.PRECISION_CHOICES,
42 #                          default=self.DAY, **kwargs)
43
44 class Work(models.Model):
45     name = models.CharField(max_length=100,
46                             help_text="Name of the context for the quote \
47                             (title of the work or speech it appears in)")
48     author = models.ForeignKey(Author)
49     date = models.DateField(blank=True, null=True,
50                             help_text="Date of the quote")
51     tags = TagField()
52
53     notes = HTMLField(blank=True, help_text= \
54                       "Notes about the work; may be left blank. Will \
55                       not be HTML-escaped. XXX: offer a WYSIWYG editor")
56     pvt_notes = HTMLField(blank=True, help_text= \
57                           "Notes about the work; not displayed on \
58                           the public interface")
59
60     def __str__(self):
61         return "%s: %s (%s)" % (self.author.name, self.name, self.date)
62
63 class Quote(models.Model):
64     text = HTMLField()
65     tags = TagField()
66     work = models.ForeignKey(Work)
67
68     notes = HTMLField(blank=True, help_text= \
69                       "Notes about the quote; may be left blank. Will \
70                       not be HTML-escaped. XXX: offer a WYSIWYG editor")
71     pvt_notes = HTMLField(blank=True, help_text= \
72                           "Notes about the quote; not displayed on \
73                           the public interface")
74
75     def __str__(self):
76         return self.work.author.name + ": " + self.text