--- /dev/null
+# -*- 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',
+ ),
+ ]
)
-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,
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()
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()