X-Git-Url: https://git.mdrn.pl/django-migdal.git/blobdiff_plain/d5a0741cc7b699d6124663921b686d14f8ad6206..d4b17ad934120d877d606b3130f826273ee49dc2:/migdal/models.py 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()