add tag and category models
authorJan Szejko <janek37@gmail.com>
Tue, 29 Nov 2016 11:56:50 +0000 (12:56 +0100)
committerJan Szejko <janek37@gmail.com>
Tue, 29 Nov 2016 11:56:50 +0000 (12:56 +0100)
apps/catalogue/migrations/0006_category_tag.py [new file with mode: 0644]
apps/catalogue/models/__init__.py
apps/catalogue/models/tag.py [new file with mode: 0644]
apps/catalogue/translation.py [new file with mode: 0644]
redakcja/settings/common.py
requirements.txt

diff --git a/apps/catalogue/migrations/0006_category_tag.py b/apps/catalogue/migrations/0006_category_tag.py
new file mode 100644 (file)
index 0000000..1cd9186
--- /dev/null
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('catalogue', '0005_auto_20150505_1229'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Category',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('label', models.CharField(max_length=64, verbose_name='category')),
+                ('label_en', models.CharField(max_length=64, null=True, verbose_name='category')),
+                ('label_pl', models.CharField(max_length=64, null=True, verbose_name='category')),
+                ('index', models.IntegerField()),
+            ],
+        ),
+        migrations.CreateModel(
+            name='Tag',
+            fields=[
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('label', models.CharField(max_length=64, verbose_name='tag')),
+                ('label_en', models.CharField(max_length=64, null=True, verbose_name='tag')),
+                ('label_pl', models.CharField(max_length=64, null=True, verbose_name='tag')),
+                ('index', models.IntegerField()),
+                ('category', models.ForeignKey(to='catalogue.Category')),
+            ],
+        ),
+    ]
index c2a067d..a940dd0 100755 (executable)
@@ -7,11 +7,13 @@ from catalogue.models.template import Template
 from catalogue.models.document import Document
 from catalogue.models.plan import Plan
 from catalogue.models.publish_log import PublishRecord
-#from catalogue.models.book import Book
-#from catalogue.models.listeners import *
+from catalogue.models.tag import Category, Tag
+# from catalogue.models.book import Book
+# from catalogue.models.listeners import *
 
 from django.contrib.auth.models import User as AuthUser
 
+
 class User(AuthUser):
     class Meta:
         proxy = True
diff --git a/apps/catalogue/models/tag.py b/apps/catalogue/models/tag.py
new file mode 100644 (file)
index 0000000..b58f458
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from __future__ import unicode_literals
+
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+
+class Category(models.Model):
+    label = models.CharField(max_length=64, verbose_name=_('category'))
+    index = models.IntegerField()
+
+
+class Tag(models.Model):
+    label = models.CharField(max_length=64, verbose_name=_('tag'))
+    category = models.ForeignKey(Category)
+    index = models.IntegerField()
diff --git a/apps/catalogue/translation.py b/apps/catalogue/translation.py
new file mode 100644 (file)
index 0000000..634a11b
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+
+from modeltranslation.translator import translator, TranslationOptions
+from catalogue.models import Tag, Category
+
+
+class TagTranslationOptions(TranslationOptions):
+    fields = ('label',)
+
+
+class CategoryTranslationOptions(TranslationOptions):
+    fields = ('label',)
+
+
+translator.register(Tag, TagTranslationOptions)
+translator.register(Category, CategoryTranslationOptions)
index 2989c1b..cd230de 100644 (file)
@@ -125,6 +125,7 @@ INSTALLED_APPS = (
     #'kombu.transport.django',
     'fileupload',
     'pipeline',
+    'modeltranslation',
 
     'catalogue',
     'cover',
index 0da5588..dd99f84 100644 (file)
@@ -23,6 +23,7 @@ python-slugify
 django-forms-bootstrap
 jsonfield
 django-email-extras
+django-modeltranslation>=0.12,<0.13
 
 celery>=3.1.12,<3.2
 kombu>3.0,<3.1