1 from django.db import models
2 from localmodels import HTMLField, TagField
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",)
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 \
25 # class DatePrecision(models.CharField):
32 # PRECISION_CHOICES = [
37 # (CENTURY, "Century"),
38 # (UNKNOWN, "Unknown"),
40 # def __init__(self, **kwargs):
41 # models.CharField(max_length=1, choices=self.PRECISION_CHOICES,
42 # default=self.DAY, **kwargs)
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")
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")
61 return "%s: %s (%s)" % (self.author.name, self.name, self.date)
63 class Quote(models.Model):
66 work = models.ForeignKey(Work)
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")
76 return self.work.author.name + ": " + self.text