]> gitweb.fperrin.net Git - djsite.git/commitdiff
Add the possibility of attaching notes to an author
authorFrédéric Perrin <fred@fperrin.net>
Wed, 28 Sep 2016 21:26:45 +0000 (22:26 +0100)
committerFrédéric Perrin <fred@fperrin.net>
Wed, 28 Sep 2016 21:26:45 +0000 (22:26 +0100)
quotes/migrations/0002_author_notes.py [new file with mode: 0644]
quotes/migrations/0003_auto_20160928_2223.py [new file with mode: 0644]
quotes/models.py
quotes/templates/quotes/author.html
quotes/templates/quotes/author_notes.html [new file with mode: 0644]
quotes/templates/quotes/onequote.html

diff --git a/quotes/migrations/0002_author_notes.py b/quotes/migrations/0002_author_notes.py
new file mode 100644 (file)
index 0000000..d7cc2f4
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('quotes', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='author',
+            name='notes',
+            field=models.TextField(blank=True),
+        ),
+    ]
diff --git a/quotes/migrations/0003_auto_20160928_2223.py b/quotes/migrations/0003_auto_20160928_2223.py
new file mode 100644 (file)
index 0000000..dc62f34
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('quotes', '0002_author_notes'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='author',
+            name='notes',
+            field=models.TextField(help_text=b'Notes for the author; may be left blank. Will                               not be HTML-escaped.', blank=True),
+        ),
+    ]
index 9791aa0b093b00eb924a76d8b0b52e1ac98574b2..53afcbe246a20f61e2c1c03767de029739540fca 100644 (file)
@@ -4,6 +4,9 @@ from django.db import models
 
 class Author(models.Model):
     name = models.CharField(max_length=100)
+    notes = models.TextField(blank=True, help_text= \
+                             "Notes for the author; may be left blank. Will \
+                              not be HTML-escaped.")
 
     def __unicode__(self):
         return self.name
index c3377ceeb3d7fdcb7d3b150e83c2cefbd7ef197e..b09befc1d7f8797fa80d729d4007992c93c1db87 100644 (file)
@@ -4,9 +4,10 @@
 
 {% block body %}
 
-
 <h1>{{ author.name }}</h1>
 
+{% include "quotes/author_notes.html" with author=author %}
+
 <p>All the quotes for {{ author.name }}:<p>
 
 {% for quote in author.quote_set.all %}
diff --git a/quotes/templates/quotes/author_notes.html b/quotes/templates/quotes/author_notes.html
new file mode 100644 (file)
index 0000000..d666de6
--- /dev/null
@@ -0,0 +1,5 @@
+{% if author.notes %}
+<div class="author_notes">
+  <p>{{ author.notes|safe }}</p>
+</div>
+{% endif %}
index 359cc7bb0ebb40b3d9f57b65d84df4a25ee77df8..e814277ba21a22e7fad356aa28d652eb67a1f796 100644 (file)
@@ -6,4 +6,6 @@
 
 {% include "quotes/display.html" with quote=quote %}
 
+{% include "quotes/author_notes.html" with author=quote.author %}
+
 {% endblock %}