simplify gallery 0.8.0
authorJan Szejko <janek37@gmail.com>
Wed, 11 Jul 2018 15:09:13 +0000 (17:09 +0200)
committerJan Szejko <janek37@gmail.com>
Wed, 11 Jul 2018 15:09:13 +0000 (17:09 +0200)
migdal/migrations/0003_auto_20180711_1503.py [new file with mode: 0644]
migdal/models.py
setup.py

diff --git a/migdal/migrations/0003_auto_20180711_1503.py b/migdal/migrations/0003_auto_20180711_1503.py
new file mode 100644 (file)
index 0000000..824cc69
--- /dev/null
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.6 on 2018-07-11 15:03
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('migdal', '0002_auto_20180710_0849'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='entry',
+            name='gallery',
+        ),
+        migrations.RemoveField(
+            model_name='photo',
+            name='gallery',
+        ),
+        migrations.AddField(
+            model_name='photo',
+            name='entry',
+            field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='migdal.Entry'),
+            preserve_default=False,
+        ),
+        migrations.AlterField(
+            model_name='photo',
+            name='image',
+            field=models.ImageField(default=0, upload_to=b'entry/photo/', verbose_name='image'),
+            preserve_default=False,
+        ),
+        migrations.DeleteModel(
+            name='PhotoGallery',
+        ),
+    ]
index 703ef21..3890f94 100644 (file)
@@ -46,18 +46,6 @@ class PublishedEntryManager(models.Manager):
             )
 
 
             )
 
 
-class PhotoGallery(models.Model):
-    key = models.CharField(max_length=64)
-
-    def __unicode__(self):
-        return self.key
-
-
-class Photo(models.Model):
-    gallery = models.ForeignKey(PhotoGallery)
-    image = models.ImageField(_('image'), upload_to='entry/photo/', null=True, blank=True)
-
-
 class Entry(models.Model):
     type = models.CharField(
         max_length=16,
 class Entry(models.Model):
     type = models.CharField(
         max_length=16,
@@ -75,7 +63,6 @@ class Entry(models.Model):
     categories = models.ManyToManyField(Category, blank=True, verbose_name=_('categories'))
     first_published_at = models.DateTimeField(_('published at'), null=True, blank=True)
     canonical_url = models.URLField(_('canonical link'), null=True, blank=True)
     categories = models.ManyToManyField(Category, blank=True, verbose_name=_('categories'))
     first_published_at = models.DateTimeField(_('published at'), null=True, blank=True)
     canonical_url = models.URLField(_('canonical link'), null=True, blank=True)
-    gallery = models.ForeignKey(PhotoGallery, null=True, blank=True)
 
     objects = models.Manager()
     published_objects = PublishedEntryManager()
 
     objects = models.Manager()
     published_objects = PublishedEntryManager()
@@ -167,6 +154,14 @@ class Attachment(models.Model):
         return self.file.url if self.file else ''
 
 
         return self.file.url if self.file else ''
 
 
+class Photo(models.Model):
+    image = models.ImageField(_('image'), upload_to='entry/photo/')
+    entry = models.ForeignKey(Entry)
+
+    def url(self):
+        return self.image.url if self.image else ''
+
+
 def notify_new_comment(sender, instance, created, **kwargs):
     if created and isinstance(instance.content_object, Entry) and instance.content_object.author_email:
         site = Site.objects.get_current()
 def notify_new_comment(sender, instance, created, **kwargs):
     if created and isinstance(instance.content_object, Entry) and instance.content_object.author_email:
         site = Site.objects.get_current()
index 96c6bd7..aaf0088 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -23,7 +23,7 @@ def whole_trees(package_dir, paths):
 
 setup(
     name='django-migdal',
 
 setup(
     name='django-migdal',
-    version='0.7.7',
+    version='0.8.0',
     author='Radek Czajka',
     author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
     maintainer='Jan Szejko',
     author='Radek Czajka',
     author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
     maintainer='Jan Szejko',