]> gitweb.fperrin.net Git - djsite.git/commitdiff
Revert "Use django-tagging for tags"
authorFrédéric Perrin <frederic.perrin@resel.fr>
Mon, 31 Oct 2016 22:51:23 +0000 (22:51 +0000)
committerFrédéric Perrin <frederic.perrin@resel.fr>
Mon, 31 Oct 2016 22:51:23 +0000 (22:51 +0000)
This reverts commit 5c563ff1701456a2ca7108a301e4e48457475daa.

14 files changed:
djsite/settings.py
quotes/admin.py
quotes/localmodels.py
quotes/migrations/0001_initial.py
quotes/migrations/0002_context_author.py [moved from quotes/migrations/0002_auto_20161031_0033.py with 55% similarity]
quotes/migrations/0003_auto_20161009_2254.py [new file with mode: 0644]
quotes/migrations/0003_auto_20161031_0034.py [deleted file]
quotes/migrations/0004_auto_20161009_2255.py [new file with mode: 0644]
quotes/migrations/0004_auto_20161031_0036.py [deleted file]
quotes/migrations/0005_auto_20161031_0052.py [deleted file]
quotes/migrations/0006_auto_20161031_0055.py [deleted file]
quotes/migrations/0007_auto_20161031_0056.py [deleted file]
quotes/models.py
quotes/views.py

index 4c0385e62b73941ecf430c1f0af922cef387e3b8..f8a06058a40bfdae467122d72b49b110c328ddc6 100644 (file)
@@ -25,7 +25,8 @@ SECRET_KEY = 's665xl1i*aa@k@-!3xnga&qf47^hl*g9z7z7r51e_3*5vqi7=m'
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True
 
-ALLOWED_HOSTS = ['quotes.fperrin.net']
+ALLOWED_HOSTS = []
+
 
 # Application definition
 
@@ -36,7 +37,6 @@ INSTALLED_APPS = (
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
-    'tagging',
     'tinymce',
     'quotes',
 )
@@ -97,7 +97,6 @@ USE_L10N = True
 
 USE_TZ = True
 
-USE_X_FORWARDED_HOST = True
 
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/1.8/howto/static-files/
index 9617bc779497b484eb9f30ec3e4d6ce10d3705d6..7e8f1adfb3a778ba4174032b6b06b8215e300ecd 100644 (file)
@@ -1,16 +1,8 @@
-from django import forms
 from django.contrib import admin
 
 # Register your models here.
-from .models import Author, Work, Quote
-#admin.site.register(Tag)
+from .models import Tag, Author, Work, Quote
+admin.site.register(Tag)
+admin.site.register(Author)
 admin.site.register(Work)
 admin.site.register(Quote)
-
-class AuthorForm(forms.ModelForm):
-#    taggit = TagField(required=False, widget=LabelWidget)
-    pass
-
-class AuthorAdmin(admin.ModelAdmin):
-    form = AuthorForm
-admin.site.register(Author, AuthorAdmin)
index 0cbb37603afd06805272de4b282a8a83092f9214..afe874a6c8c8938f2412aa3873e5fc3250240613 100644 (file)
@@ -10,10 +10,3 @@ class HTMLField(tinymce.models.HTMLField):
         safe_value = valid_html(value)
         setattr(model_instance, self.attname, safe_value)
         return safe_value
-
-import tagging.fields
-
-class TagField(tagging.fields.TagField):
-    def __init__(self, *args, **kwargs):
-        kwargs.setdefault('help_text', 'Space-separated list of tags')
-        return tagging.fields.TagField.__init__(self, *args, **kwargs)
index 927cce952bf1bbc33259c6d499cb9e36288cfeff..c7f97c4a58b7a20b0ae950315b5a987e161ac993 100644 (file)
@@ -1,16 +1,11 @@
 # -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:22
 from __future__ import unicode_literals
 
 from django.db import migrations, models
-import django.db.models.deletion
-import quotes.localmodels
 
 
 class Migration(migrations.Migration):
 
-    initial = True
-
     dependencies = [
     ]
 
@@ -18,55 +13,54 @@ class Migration(migrations.Migration):
         migrations.CreateModel(
             name='Author',
             fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('name', models.CharField(help_text=b'Name of the author', max_length=100)),
-                ('notes', quotes.localmodels.HTMLField(blank=True, help_text=b'Notes about the author; may be left blank. Will                       not be HTML-escaped.')),
-                ('pvt_notes', quotes.localmodels.HTMLField(blank=True, help_text=b'Notes about the author; not displayed on                           the public interface')),
-                ('birth_date', models.DateField(blank=True, help_text=b'Date of birth', null=True)),
-                ('death_date', models.DateField(blank=True, help_text=b'Date of death (leave blank                                   if still alive!)', null=True)),
+                ('notes', models.TextField(help_text=b'Notes about the author; may be left blank. Will                               not be HTML-escaped.', blank=True)),
+                ('pvt_notes', models.TextField(help_text=b'Notes about the author; not displayed on                                   the public interface', blank=True)),
+                ('birth_date', models.DateField(help_text=b'Date of birth', null=True, blank=True)),
+                ('death_date', models.DateField(help_text=b'Date of death (leave blank                                   if still alive!)', null=True, blank=True)),
             ],
         ),
         migrations.CreateModel(
-            name='Quote',
+            name='Context',
             fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('text', quotes.localmodels.HTMLField()),
-                ('notes', quotes.localmodels.HTMLField(blank=True, help_text=b'Notes about the quote; may be left blank. Will                       not be HTML-escaped. XXX: offer a WYSIWYG editor')),
-                ('pvt_notes', quotes.localmodels.HTMLField(blank=True, help_text=b'Notes about the quote; not displayed on                           the public interface')),
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('name', models.CharField(help_text=b'Name of the context for the quote                             (title of the work or speech it appears in)', max_length=100)),
+                ('date', models.DateField(help_text=b'Date of the quote', null=True, blank=True)),
+                ('notes', models.TextField(help_text=b'Notes about the work; may be left blank. Will                               not be HTML-escaped. XXX: offer a WYSIWYG editor', blank=True)),
+                ('pvt_notes', models.TextField(help_text=b'Notes about the work; not displayed on                                   the public interface', blank=True)),
             ],
         ),
         migrations.CreateModel(
-            name='Tag',
+            name='Quote',
             fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('tag', models.CharField(max_length=100)),
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('text', models.TextField()),
+                ('notes', models.TextField(help_text=b'Notes about the quote; may be left blank. Will                               not be HTML-escaped. XXX: offer a WYSIWYG editor', blank=True)),
+                ('pvt_notes', models.TextField(help_text=b'Notes about the quote; not displayed on                                   the public interface', blank=True)),
+                ('context', models.ForeignKey(to='quotes.Context')),
             ],
         ),
         migrations.CreateModel(
-            name='Work',
+            name='Tag',
             fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('name', models.CharField(help_text=b'Name of the context for the quote                             (title of the work or speech it appears in)', max_length=100)),
-                ('date', models.DateField(blank=True, help_text=b'Date of the quote', null=True)),
-                ('notes', quotes.localmodels.HTMLField(blank=True, help_text=b'Notes about the work; may be left blank. Will                       not be HTML-escaped. XXX: offer a WYSIWYG editor')),
-                ('pvt_notes', quotes.localmodels.HTMLField(blank=True, help_text=b'Notes about the work; not displayed on                           the public interface')),
-                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quotes.Author')),
-                ('tags', models.ManyToManyField(blank=True, to='quotes.Tag')),
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('tag', models.CharField(max_length=100)),
             ],
         ),
         migrations.AddField(
             model_name='quote',
             name='tags',
-            field=models.ManyToManyField(blank=True, to='quotes.Tag'),
+            field=models.ManyToManyField(to='quotes.Tag', blank=True),
         ),
         migrations.AddField(
-            model_name='quote',
-            name='work',
-            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='quotes.Work'),
+            model_name='context',
+            name='tags',
+            field=models.ManyToManyField(to='quotes.Tag', blank=True),
         ),
         migrations.AddField(
             model_name='author',
             name='tags',
-            field=models.ManyToManyField(blank=True, to='quotes.Tag'),
+            field=models.ManyToManyField(to='quotes.Tag', blank=True),
         ),
     ]
similarity index 55%
rename from quotes/migrations/0002_auto_20161031_0033.py
rename to quotes/migrations/0002_context_author.py
index f83d287e79f7cb1050f30f4ab91e0241dd11d9dd..79ca5e31a0316e0d4186af9eac4bd3280c53dce8 100644 (file)
@@ -1,5 +1,4 @@
 # -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:33
 from __future__ import unicode_literals
 
 from django.db import migrations, models
@@ -12,9 +11,10 @@ class Migration(migrations.Migration):
     ]
 
     operations = [
-        migrations.AlterField(
-            model_name='author',
-            name='tags',
-            field=models.ManyToManyField(to='quotes.Tag'),
+        migrations.AddField(
+            model_name='context',
+            name='author',
+            field=models.ForeignKey(default=1, to='quotes.Author'),
+            preserve_default=False,
         ),
     ]
diff --git a/quotes/migrations/0003_auto_20161009_2254.py b/quotes/migrations/0003_auto_20161009_2254.py
new file mode 100644 (file)
index 0000000..b3b0366
--- /dev/null
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('quotes', '0002_context_author'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Work',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('name', models.CharField(help_text=b'Name of the context for the quote                             (title of the work or speech it appears in)', max_length=100)),
+                ('date', models.DateField(help_text=b'Date of the quote', null=True, blank=True)),
+                ('notes', models.TextField(help_text=b'Notes about the work; may be left blank. Will                               not be HTML-escaped. XXX: offer a WYSIWYG editor', blank=True)),
+                ('pvt_notes', models.TextField(help_text=b'Notes about the work; not displayed on                                   the public interface', blank=True)),
+                ('author', models.ForeignKey(to='quotes.Author')),
+                ('tags', models.ManyToManyField(to='quotes.Tag', blank=True)),
+            ],
+        ),
+        migrations.RemoveField(
+            model_name='context',
+            name='author',
+        ),
+        migrations.RemoveField(
+            model_name='context',
+            name='tags',
+        ),
+        migrations.AlterField(
+            model_name='quote',
+            name='context',
+            field=models.ForeignKey(to='quotes.Work'),
+        ),
+        migrations.DeleteModel(
+            name='Context',
+        ),
+    ]
diff --git a/quotes/migrations/0003_auto_20161031_0034.py b/quotes/migrations/0003_auto_20161031_0034.py
deleted file mode 100644 (file)
index baab095..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:34
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('quotes', '0002_auto_20161031_0033'),
-    ]
-
-    operations = [
-        migrations.AlterField(
-            model_name='author',
-            name='tags',
-            field=models.ManyToManyField(blank=True, to='quotes.Tag'),
-        ),
-    ]
diff --git a/quotes/migrations/0004_auto_20161009_2255.py b/quotes/migrations/0004_auto_20161009_2255.py
new file mode 100644 (file)
index 0000000..cf435ab
--- /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', '0003_auto_20161009_2254'),
+    ]
+
+    operations = [
+        migrations.RenameField(
+            model_name='quote',
+            old_name='context',
+            new_name='work',
+        ),
+    ]
diff --git a/quotes/migrations/0004_auto_20161031_0036.py b/quotes/migrations/0004_auto_20161031_0036.py
deleted file mode 100644 (file)
index 2e67927..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:36
-from __future__ import unicode_literals
-
-from django.db import migrations
-import tagging.fields
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('quotes', '0003_auto_20161031_0034'),
-    ]
-
-    operations = [
-        migrations.AddField(
-            model_name='author',
-            name='tagbis',
-            field=tagging.fields.TagField(blank=True, max_length=255),
-        ),
-        migrations.AddField(
-            model_name='work',
-            name='tagter',
-            field=tagging.fields.TagField(blank=True, max_length=255),
-        ),
-    ]
diff --git a/quotes/migrations/0005_auto_20161031_0052.py b/quotes/migrations/0005_auto_20161031_0052.py
deleted file mode 100644 (file)
index ad509a7..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:52
-from __future__ import unicode_literals
-
-from django.db import migrations
-import quotes.localmodels
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('quotes', '0004_auto_20161031_0036'),
-    ]
-
-    operations = [
-        migrations.RemoveField(
-            model_name='author',
-            name='tagbis',
-        ),
-        migrations.RemoveField(
-            model_name='work',
-            name='tagter',
-        ),
-        migrations.RemoveField(
-            model_name='author',
-            name='tags',
-        ),
-        migrations.AddField(
-            model_name='author',
-            name='tags',
-            field=quotes.localmodels.TagField(blank=True, max_length=255),
-        ),
-        migrations.RemoveField(
-            model_name='quote',
-            name='tags',
-        ),
-        migrations.AddField(
-            model_name='quote',
-            name='tags',
-            field=quotes.localmodels.TagField(blank=True, max_length=255),
-        ),
-        migrations.RemoveField(
-            model_name='work',
-            name='tags',
-        ),
-        migrations.AddField(
-            model_name='work',
-            name='tags',
-            field=quotes.localmodels.TagField(blank=True, max_length=255),
-        ),
-        migrations.DeleteModel(
-            name='Tag',
-        ),
-    ]
diff --git a/quotes/migrations/0006_auto_20161031_0055.py b/quotes/migrations/0006_auto_20161031_0055.py
deleted file mode 100644 (file)
index 047eed7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:55
-from __future__ import unicode_literals
-
-from django.db import migrations
-import quotes.localmodels
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('quotes', '0005_auto_20161031_0052'),
-    ]
-
-    operations = [
-        migrations.RemoveField(
-            model_name='author',
-            name='tags',
-        ),
-        migrations.AddField(
-            model_name='author',
-            name='tag',
-            field=quotes.localmodels.TagField(blank=True, max_length=255),
-        ),
-    ]
diff --git a/quotes/migrations/0007_auto_20161031_0056.py b/quotes/migrations/0007_auto_20161031_0056.py
deleted file mode 100644 (file)
index c01a8a4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10.2 on 2016-10-31 00:56
-from __future__ import unicode_literals
-
-from django.db import migrations
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('quotes', '0006_auto_20161031_0055'),
-    ]
-
-    operations = [
-        migrations.RenameField(
-            model_name='author',
-            old_name='tag',
-            new_name='tags',
-        ),
-    ]
index 7539152451509845f8e984c31bbd16c2dd4ddb69..0fa66afd0ed91e8e076bd7d674c068246ef09b46 100644 (file)
@@ -1,7 +1,12 @@
 from django.db import models
-from localmodels import HTMLField, TagField
+from localmodels import HTMLField
 
 # 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")
@@ -11,7 +16,7 @@ class Author(models.Model):
     pvt_notes = HTMLField(blank=True, help_text= \
                           "Notes about the author; not displayed on \
                           the public interface",)
-    tags = TagField()
+    tags = models.ManyToManyField(Tag, blank=True)
 
     birth_date = models.DateField(blank=True, null=True,
                                   help_text="Date of birth")
@@ -48,7 +53,7 @@ class Work(models.Model):
     author = models.ForeignKey(Author)
     date = models.DateField(blank=True, null=True,
                             help_text="Date of the quote")
-    tags = TagField()
+    tags = models.ManyToManyField(Tag, blank=True)
 
     notes = HTMLField(blank=True, help_text= \
                       "Notes about the work; may be left blank. Will \
@@ -62,7 +67,7 @@ class Work(models.Model):
 
 class Quote(models.Model):
     text = HTMLField()
-    tags = TagField()
+    tags = models.ManyToManyField(Tag, blank=True)
     work = models.ForeignKey(Work)
 
     notes = HTMLField(blank=True, help_text= \
index 002c4e34a6b8ada081f5ffcd0ffab4663c204d7a..df4081d5b79b251ff5523b98d283dd470b2367d2 100644 (file)
@@ -2,7 +2,7 @@ from django.shortcuts import render
 
 from random import randint
 
-from .models import Author, Work, Quote
+from .models import Author, Work, Quote, Tag
 
 # Create your views here.
 def onequote(request, quote_id):