1 from django.db import models
2 from localmodels import HTMLField
4 # Create your models here.
5 class BaseTag(models.Model):
6 tag = models.CharField(max_length=100, unique=True)
14 class AuthorTag(BaseTag): pass
15 class WorkTag(BaseTag): pass
16 class QuoteTag(BaseTag): pass
18 class CommonData(models.Model):
19 creation_date = models.DateTimeField(auto_now_add=True)
20 last_modification = models.DateTimeField(auto_now=True)
22 notes = HTMLField(blank=True, help_text= \
23 "Notes about the entry; may be left blank. Displayed \
25 pvt_notes = HTMLField(blank=True, help_text= \
26 "Notes about the entry; not displayed on \
27 the public interface")
32 class Author(CommonData):
33 name = models.CharField(max_length=100,
34 help_text="Name of the author",
37 tags = models.ManyToManyField(AuthorTag, blank=True,
38 help_text='Not implemented yet')
40 birth_date = models.DateField(blank=True, null=True,
41 help_text="Date of birth")
42 death_date = models.DateField(blank=True, null=True,
43 help_text="Date of death (leave blank \
49 # class DatePrecision(models.CharField):
56 # PRECISION_CHOICES = [
61 # (CENTURY, "Century"),
62 # (UNKNOWN, "Unknown"),
64 # def __init__(self, **kwargs):
65 # models.CharField(max_length=1, choices=self.PRECISION_CHOICES,
66 # default=self.DAY, **kwargs)
68 class Work(CommonData):
69 name = models.CharField(max_length=100,
70 help_text="Name of the context for the quote \
71 (title of the work or speech it appears in)",
73 author = models.ForeignKey(Author)
74 date = models.DateField(blank=True, null=True,
75 help_text="Date of the quote")
76 tags = models.ManyToManyField(WorkTag, blank=True,
77 help_text='Not implemented yet')
80 return "%s: %s (%s)" % (self.author.name, self.name, self.date)
82 class Quote(CommonData):
84 tags = models.ManyToManyField(QuoteTag, blank=True)
85 work = models.ForeignKey(Work)
88 return self.work.author.name + ": " + self.text