]> gitweb.fperrin.net Git - djsite.git/commitdiff
Fix display when quotes contain unicode
authorFrédéric Perrin <frederic.perrin@resel.fr>
Sat, 12 Nov 2016 10:26:45 +0000 (10:26 +0000)
committerFrédéric Perrin <frederic.perrin@resel.fr>
Sat, 12 Nov 2016 10:26:45 +0000 (10:26 +0000)
quotes/models.py
quotes/test_quotes.py

index da6f93bf9bc414f6108cec7ee8772d8dc370f6b3..0d7fe333001e4ee77f58216f1ed102cc9c903343 100644 (file)
@@ -52,7 +52,7 @@ class Author(CommonData):
                                   help_text="Date of death (leave blank \
                                   if still alive!)")
 
                                   help_text="Date of death (leave blank \
                                   if still alive!)")
 
-    def __str__(self):
+    def __unicode__(self):
         return self.name
 
     def get_absolute_url(self):
         return self.name
 
     def get_absolute_url(self):
@@ -88,7 +88,7 @@ class Work(CommonData):
     tags = models.ManyToManyField(WorkTag, blank=True,
                                   help_text='Not implemented yet')
 
     tags = models.ManyToManyField(WorkTag, blank=True,
                                   help_text='Not implemented yet')
 
-    def __str__(self):
+    def __unicode__(self):
         return "%s: %s (%s)" % (self.author.name, self.name, self.date)
 
     def get_absolute_url(self):
         return "%s: %s (%s)" % (self.author.name, self.name, self.date)
 
     def get_absolute_url(self):
@@ -99,7 +99,7 @@ class Quote(CommonData):
     tags = models.ManyToManyField(QuoteTag, blank=True)
     work = models.ForeignKey(Work)
 
     tags = models.ManyToManyField(QuoteTag, blank=True)
     work = models.ForeignKey(Work)
 
-    def __str__(self):
+    def __unicode__(self):
         return self.work.author.name + ": " + self.text
 
     def get_absolute_url(self):
         return self.work.author.name + ": " + self.text
 
     def get_absolute_url(self):
index b194ec111e3f18d1c73bb9817de038df8957c0bc..d3e65e556aa6195dd87fa32f7c92d09b9b1b3a1d 100644 (file)
@@ -1,3 +1,5 @@
+# -*- encoding: utf-8 -*-
+
 import pytest
 
 from .models import QuoteTag, Author, Work, Quote
 import pytest
 
 from .models import QuoteTag, Author, Work, Quote
@@ -142,3 +144,19 @@ class Test_Views():
 
         authorpage = c.getPage('author/%s/' % a.id)
         assert authorpage.count("Some notes for the author") == 1
 
         authorpage = c.getPage('author/%s/' % a.id)
         assert authorpage.count("Some notes for the author") == 1
+
+class Test_Unicode():
+    def test_unicode(self, db):
+        a = Author.objects.create(name="ê è  “smart ''quotes,”")
+        w = Work.objects.create(name="¿who?If you’re creati'' ng a", author=a)
+        q = Quote.objects.create(text="µqwer If you’r'' ¨ë ẽ « or » e ", work=w)
+        t = QuoteTag.objects.create(tag=", “s tag 'a’ ß")
+
+        for t in QuoteTag.objects.all():
+            print t
+        for w in Work.objects.all():
+            print w
+        for a in Author.objects.all():
+            print a
+        for q in Quote.objects.all():
+            print q