From: Jan Szejko Date: Wed, 11 Jul 2018 15:09:13 +0000 (+0200) Subject: simplify gallery X-Git-Tag: 0.8.0 X-Git-Url: https://git.mdrn.pl/django-migdal.git/commitdiff_plain/d4b17ad934120d877d606b3130f826273ee49dc2?hp=d5a0741cc7b699d6124663921b686d14f8ad6206 simplify gallery --- diff --git a/migdal/migrations/0003_auto_20180711_1503.py b/migdal/migrations/0003_auto_20180711_1503.py new file mode 100644 index 0000000..824cc69 --- /dev/null +++ b/migdal/migrations/0003_auto_20180711_1503.py @@ -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', + ), + ] diff --git a/migdal/models.py b/migdal/models.py index 703ef21..3890f94 100644 --- a/migdal/models.py +++ b/migdal/models.py @@ -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, @@ -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) - gallery = models.ForeignKey(PhotoGallery, null=True, blank=True) objects = models.Manager() published_objects = PublishedEntryManager() @@ -167,6 +154,14 @@ class Attachment(models.Model): 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() diff --git a/setup.py b/setup.py index 96c6bd7..aaf0088 100755 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def whole_trees(package_dir, paths): 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',