From: Guillaume Pellerin Date: Fri, 19 Aug 2016 14:37:29 +0000 (+0200) Subject: Move Photo to core X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c8ad6637be35c801290a72964e7877ca3bb2f0d3;p=mezzo.git Move Photo to core --- diff --git a/app/local_settings.py b/app/local_settings.py index 8677ccaa..3f482832 100644 --- a/app/local_settings.py +++ b/app/local_settings.py @@ -70,7 +70,7 @@ SILENCED_SYSTEM_CHECKS = ['fields.W342',] ADMIN_MENU_ORDER = ( (_('Pages'), ('pages.Page', 'organization-featured.Featured', 'organization-pages.Home')), - (_('Media'), ('organization-media.Video', 'organization-media.VideoCategory', 'organization-media.Audio', 'organization-media.Playlist', 'organization-media.Photo', (_('Media Library'), 'fb_browse'),)), + (_('Media'), ('organization-media.Video', 'organization-media.VideoCategory', 'organization-media.Audio', 'organization-media.Playlist', (_('Media Library'), 'fb_browse'),)), (_('Events'), ('mezzanine_agenda.Event', 'mezzanine_agenda.EventLocation', 'mezzanine_agenda.EventCategory', 'mezzanine_agenda.EventPrice',)), (_('Magazine'), ('organization-magazine.Article', 'organization-magazine.Brief',)), (_('Organization'), ('organization-team.Organization', 'organization-team.Department', 'organization-team.Team', 'organization-team.Person', 'organization-team.Activity', 'organization-team.OrganizationType',)), diff --git a/app/organization/core/models.py b/app/organization/core/models.py index 118ddd46..1170ddaf 100644 --- a/app/organization/core/models.py +++ b/app/organization/core/models.py @@ -8,9 +8,10 @@ from django.contrib.contenttypes.fields import GenericForeignKey from mezzanine.pages.models import Page, RichText from mezzanine.core.fields import RichTextField, OrderField, FileField from mezzanine.core.models import Displayable, Slugged, Orderable -from organization.media.models import Photo + COLOR_CHOICES = (('black', _('black')), ('yellow', _('yellow')), ('red', _('red'))) +ALIGNMENT_CHOICES = (('left', _('left')), ('center', _('center')), ('right', _('right'))) class Description(models.Model): @@ -68,6 +69,32 @@ class Category(Named): return self.name +class Photo(models.Model): + """Photo bundle with credits""" + + photo = FileField(_('photo'), upload_to='images/photos', max_length=1024, blank=True, format="Image") + photo_credits = models.CharField(_('photo credits'), max_length=255, blank=True, null=True) + photo_alignment = models.CharField(_('photo alignment'), choices=ALIGNMENT_CHOICES, max_length=32, default="left", blank=True) + photo_description = models.TextField(_('photo description'), blank=True) + + photo_card = FileField(_('card photo'), upload_to='images/photos/card', max_length=1024, blank=True, format="Image") + photo_card_credits = models.CharField(_('photo card credits'), max_length=255, blank=True, null=True) + + photo_slider = FileField(_('slider photo'), upload_to='images/photos/slider', max_length=1024, blank=True, format="Image") + photo_slider_credits = models.CharField(_('photo slider credits'), max_length=255, blank=True, null=True) + abstract = True + + class Meta: + abstract = True + + @property + def card(self): + if self.photo_card: + return self.photo_card + else: + return self.photo + + class BasicPage(Page, SubTitle, Photo, RichText): class Meta: @@ -106,6 +133,7 @@ class DynamicContent(models.Model): class Meta: abstract = True + class Image(Description, Orderable): file = FileField(_("Image"), max_length=1024, format="Image", upload_to="images") diff --git a/app/organization/festival/models.py b/app/organization/festival/models.py index 430ac4bf..5b110a40 100644 --- a/app/organization/festival/models.py +++ b/app/organization/festival/models.py @@ -10,7 +10,6 @@ from mezzanine.blog.models import BlogPost from mezzanine.pages.models import Page from organization.core.models import * -from organization.media.models import * import requests from pyquery import PyQuery as pq diff --git a/app/organization/magazine/models.py b/app/organization/magazine/models.py index 01595dca..a5e02f11 100644 --- a/app/organization/magazine/models.py +++ b/app/organization/magazine/models.py @@ -11,8 +11,7 @@ from mezzanine.core.models import RichText, Displayable, Slugged from mezzanine.pages.models import Page from mezzanine.blog.models import BlogPost #from orderable.models import Orderable -from organization.core.models import Named, Description, Image -from organization.media.models import Photo +from organization.core.models import Named, Description, Image, Photo class ArticleImage(Image): diff --git a/app/organization/media/models.py b/app/organization/media/models.py index a85187c2..d13c8a6d 100644 --- a/app/organization/media/models.py +++ b/app/organization/media/models.py @@ -10,33 +10,8 @@ from mezzanine.utils.models import AdminThumbMixin, upload_to from mezzanine_agenda.models import Event from django.conf import settings -ALIGNMENT_CHOICES = (('left', _('left')), ('center', _('center')), ('right', _('right'))) -MEDIA_BASE_URL = getattr(settings, 'MEDIA_BASE_URL', 'http://medias.ircam.fr/embed/media/') - - -class Photo(models.Model): - """Photo bundle with credits""" - - photo = FileField(_('photo'), upload_to='images/photos', max_length=1024, blank=True, format="Image") - photo_credits = models.CharField(_('photo credits'), max_length=255, blank=True, null=True) - photo_alignment = models.CharField(_('photo alignment'), choices=ALIGNMENT_CHOICES, max_length=32, default="left", blank=True) - photo_description = models.TextField(_('photo description'), blank=True) - - photo_card = FileField(_('card photo'), upload_to='images/photos/card', max_length=1024, blank=True, format="Image") - photo_card_credits = models.CharField(_('photo card credits'), max_length=255, blank=True, null=True) - - photo_slider = FileField(_('slider photo'), upload_to='images/photos/slider', max_length=1024, blank=True, format="Image") - photo_slider_credits = models.CharField(_('photo slider credits'), max_length=255, blank=True, null=True) - class Meta: - abstract = True - - @property - def card(self): - if self.photo_card: - return self.photo_card - else: - return self.photo +MEDIA_BASE_URL = getattr(settings, 'MEDIA_BASE_URL', 'http://medias.ircam.fr/embed/media/') class Media(Displayable, RichText): diff --git a/app/organization/team/models.py b/app/organization/team/models.py index b8eec860..dfd653c8 100644 --- a/app/organization/team/models.py +++ b/app/organization/team/models.py @@ -21,7 +21,6 @@ from mezzanine.core.fields import RichTextField, OrderField, FileField from mezzanine.utils.models import AdminThumbMixin, upload_to from mezzanine.galleries.models import BaseGallery -from organization.media.models import Photo from organization.core.models import * from organization.magazine.models import Article