]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/models.py
Add HTML validation
[djsite.git] / quotes / models.py
index cdae648e21960c540bc2dbab1b9b8334ffdf9344..0fa66afd0ed91e8e076bd7d674c068246ef09b46 100644 (file)
@@ -1,5 +1,5 @@
 from django.db import models
-from tinymce import models as tinymce_models
+from localmodels import HTMLField
 
 # Create your models here.
 class Tag(models.Model):
@@ -10,12 +10,12 @@ class Tag(models.Model):
 class Author(models.Model):
     name = models.CharField(max_length=100,
                             help_text="Name of the author")
-    notes = tinymce_models.HTMLField(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",)
+    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 = models.ManyToManyField(Tag, blank=True)
 
     birth_date = models.DateField(blank=True, null=True,
@@ -24,7 +24,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):
@@ -55,27 +55,27 @@ class Work(models.Model):
                             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")
+    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 __str__(self):
         return "%s: %s (%s)" % (self.author.name, self.name, self.date)
 
 class Quote(models.Model):
-    text = models.TextField()
+    text = HTMLField()
     tags = models.ManyToManyField(Tag, blank=True)
     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