]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/models.py
Add a 'work' concept
[djsite.git] / quotes / models.py
index 53afcbe246a20f61e2c1c03767de029739540fca..9c65abc3c42862939534360a08ba0456ed98b8a9 100644 (file)
@@ -2,29 +2,80 @@ from django.db import models
 
 # Create your models here.
 
+class Tag(models.Model):
+    tag = models.CharField(max_length=100)
+    def __unicode__(self):
+        return self.tag
+
 class Author(models.Model):
-    name = models.CharField(max_length=100)
+    name = models.CharField(max_length=100,
+                            help_text="Name of the author")
     notes = models.TextField(blank=True, help_text= \
-                             "Notes for the author; may be left blank. Will \
+                             "Notes about the author; may be left blank. Will \
                               not be HTML-escaped.")
+    pvt_notes = models.TextField(blank=True, help_text= \
+                                 "Notes about the author; not displayed on \
+                                  the public interface")
+    tags = models.ManyToManyField(Tag, blank=True)
+
+    birth_date = models.DateField(blank=True, null=True,
+                                  help_text="Date of birth")
+    death_date = models.DateField(blank=True, null=True,
+                                  help_text="Date of death (leave blank \
+                                  if still alive!)")
 
     def __unicode__(self):
         return self.name
 
-class Tag(models.Model):
-    tag = models.CharField(max_length=100)
+# class DatePrecision(models.CharField):
+#     DAY = "D"
+#     MONTH = "M"
+#     YEAR = "Y"
+#     DECADE = "X"
+#     CENTURY = "C"
+#     UNKNOWN = "?"
+#     PRECISION_CHOICES = [
+#         (DAY, "Day"),
+#         (MONTH, "Month"),
+#         (YEAR, "Year"),
+#         (DECADE, "Decade"),
+#         (CENTURY, "Century"),
+#         (UNKNOWN, "Unknown"),
+#     ]
+#     def __init__(self, **kwargs):
+#         models.CharField(max_length=1, choices=self.PRECISION_CHOICES,
+#                          default=self.DAY, **kwargs)
 
-    def __unicode__(self):
-        return self.tag
+class Work(models.Model):
+    name = models.CharField(max_length=100,
+                            help_text="Name of the context for the quote \
+                            (title of the work or speech it appears in)")
+    author = models.ForeignKey(Author)
+    date = models.DateField(blank=True, null=True,
+                            help_text="Date of the quote")
+    tags = models.ManyToManyField(Tag, blank=True)
+
+    notes = models.TextField(blank=True, help_text= \
+                             "Notes about the work; may be left blank. Will \
+                              not be HTML-escaped. XXX: offer a WYSIWYG editor")
+    pvt_notes = models.TextField(blank=True, help_text= \
+                                 "Notes about the work; not displayed on \
+                                  the public interface")
 
-    class Meta:
-        ordering = ("tag", )
+    def __unicode__(self):
+        return "%s: %s (%s)" % (self.author.name, self.name, self.date)
 
 class Quote(models.Model):
     text = models.TextField()
-    author = models.ForeignKey(Author)
     tags = models.ManyToManyField(Tag, blank=True)
+    work = models.ForeignKey(Work)
 
-    def __unicode__(self):
-        return self.author.name + ": " + self.text
+    notes = models.TextField(blank=True, help_text= \
+                             "Notes about the quote; may be left blank. Will \
+                              not be HTML-escaped. XXX: offer a WYSIWYG editor")
+    pvt_notes = models.TextField(blank=True, help_text= \
+                                 "Notes about the quote; not displayed on \
+                                  the public interface")
 
+    def __unicode__(self):
+        return self.work.author.name + ": " + self.text