1 from django.db import models
3 # Create your models here.
5 class Tag(models.Model):
6 tag = models.CharField(max_length=100)
10 class Author(models.Model):
11 name = models.CharField(max_length=100,
12 help_text="Name of the author")
13 notes = models.TextField(blank=True, help_text= \
14 "Notes about the author; may be left blank. Will \
15 not be HTML-escaped.")
16 pvt_notes = models.TextField(blank=True, help_text= \
17 "Notes about the author; not displayed on \
18 the public interface")
19 tags = models.ManyToManyField(Tag, blank=True)
21 birth_date = models.DateField(blank=True, null=True,
22 help_text="Date of birth")
23 death_date = models.DateField(blank=True, null=True,
24 help_text="Date of death (leave blank \
27 def __unicode__(self):
30 # class DatePrecision(models.CharField):
37 # PRECISION_CHOICES = [
42 # (CENTURY, "Century"),
43 # (UNKNOWN, "Unknown"),
45 # def __init__(self, **kwargs):
46 # models.CharField(max_length=1, choices=self.PRECISION_CHOICES,
47 # default=self.DAY, **kwargs)
49 class Work(models.Model):
50 name = models.CharField(max_length=100,
51 help_text="Name of the context for the quote \
52 (title of the work or speech it appears in)")
53 author = models.ForeignKey(Author)
54 date = models.DateField(blank=True, null=True,
55 help_text="Date of the quote")
56 tags = models.ManyToManyField(Tag, blank=True)
58 notes = models.TextField(blank=True, help_text= \
59 "Notes about the work; may be left blank. Will \
60 not be HTML-escaped. XXX: offer a WYSIWYG editor")
61 pvt_notes = models.TextField(blank=True, help_text= \
62 "Notes about the work; not displayed on \
63 the public interface")
65 def __unicode__(self):
66 return "%s: %s (%s)" % (self.author.name, self.name, self.date)
68 class Quote(models.Model):
69 text = models.TextField()
70 tags = models.ManyToManyField(Tag, blank=True)
71 work = models.ForeignKey(Work)
73 notes = models.TextField(blank=True, help_text= \
74 "Notes about the quote; may be left blank. Will \
75 not be HTML-escaped. XXX: offer a WYSIWYG editor")
76 pvt_notes = models.TextField(blank=True, help_text= \
77 "Notes about the quote; not displayed on \
78 the public interface")
80 def __unicode__(self):
81 return self.work.author.name + ": " + self.text