X-Git-Url: http://gitweb.fperrin.net/?p=djsite.git;a=blobdiff_plain;f=quotes%2Fmodels.py;h=7539152451509845f8e984c31bbd16c2dd4ddb69;hp=9c65abc3c42862939534360a08ba0456ed98b8a9;hb=5c563ff1701456a2ca7108a301e4e48457475daa;hpb=13c2e4fc8a5506cfa074c06335a73d28a173aba9 diff --git a/quotes/models.py b/quotes/models.py index 9c65abc..7539152 100644 --- a/quotes/models.py +++ b/quotes/models.py @@ -1,22 +1,17 @@ from django.db import models +from localmodels import HTMLField, TagField # 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, help_text="Name of the author") - notes = models.TextField(blank=True, help_text= \ - "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) + notes = HTMLField(blank=True, help_text= \ + "Notes about the author; may be left blank. Will \ + not be HTML-escaped.",) + pvt_notes = HTMLField(blank=True, help_text= \ + "Notes about the author; not displayed on \ + the public interface",) + tags = TagField() birth_date = models.DateField(blank=True, null=True, help_text="Date of birth") @@ -24,7 +19,7 @@ class Author(models.Model): help_text="Date of death (leave blank \ if still alive!)") - def __unicode__(self): + def __str__(self): return self.name # class DatePrecision(models.CharField): @@ -53,29 +48,29 @@ class Work(models.Model): author = models.ForeignKey(Author) date = models.DateField(blank=True, null=True, help_text="Date of the quote") - tags = models.ManyToManyField(Tag, blank=True) + tags = TagField() - 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") + notes = HTMLField(blank=True, help_text= \ + "Notes about the work; may be left blank. Will \ + not be HTML-escaped. XXX: offer a WYSIWYG editor") + pvt_notes = HTMLField(blank=True, help_text= \ + "Notes about the work; not displayed on \ + the public interface") - def __unicode__(self): + def __str__(self): return "%s: %s (%s)" % (self.author.name, self.name, self.date) class Quote(models.Model): - text = models.TextField() - tags = models.ManyToManyField(Tag, blank=True) + text = HTMLField() + tags = TagField() work = models.ForeignKey(Work) - 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") + notes = HTMLField(blank=True, help_text= \ + "Notes about the quote; may be left blank. Will \ + not be HTML-escaped. XXX: offer a WYSIWYG editor") + pvt_notes = HTMLField(blank=True, help_text= \ + "Notes about the quote; not displayed on \ + the public interface") - def __unicode__(self): + def __str__(self): return self.work.author.name + ": " + self.text