]> git.parisson.com Git - mezzo.git/commitdiff
add media model and Photos bundle
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 6 Jul 2016 15:51:12 +0000 (17:51 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 6 Jul 2016 15:51:12 +0000 (17:51 +0200)
app/custom/models.py
app/media/__init__.py [new file with mode: 0644]
app/media/admin.py [new file with mode: 0644]
app/media/apps.py [new file with mode: 0644]
app/media/migrations/__init__.py [new file with mode: 0644]
app/media/models.py [new file with mode: 0644]
app/media/tests.py [new file with mode: 0644]
app/media/views.py [new file with mode: 0644]
app/organization/models.py

index fb186b1982ae22cd2c9e8615edfe703fd38968e1..46b58bf564b45f6c088c269ab720370e47c1e707 100644 (file)
@@ -5,24 +5,21 @@ from mezzanine.pages.models import Page, RichText
 from mezzanine.core.fields import RichTextField, OrderField, FileField
 from django.conf import settings
 
+from media.models import Photos
+
 ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right')))
 MEDIA_BASE_URL = getattr(settings, 'MEDIA_BASE_URL', 'http://medias.ircam.fr/embed/media/')
 
+
 class SubTitle(models.Model):
 
-    sub_title = models.TextField(_('sub title'), blank=True)
+    sub_title = models.TextField(_('sub title'), blank=True, max_length=1024)
 
     class Meta:
         abstract = True
 
 
-class BasicPage(Page, RichText):
+class BasicPage(Page, RichText, SubTitle, Photos):
 
-    sub_title = models.CharField(_('sub title'), blank=True, max_length=1000)
-    # description = models.TextField(_('description'), blank=True)
-    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_featured = FileField(_('photo featured'), upload_to='images/photos', max_length=1024, blank=True, format="Image")
-    photo_featured_credits = models.CharField(_('photo featured credits'), max_length=255, blank=True, null=True)
+    class Meta:
+        verbose_name = 'basic page'
diff --git a/app/media/__init__.py b/app/media/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/app/media/admin.py b/app/media/admin.py
new file mode 100644 (file)
index 0000000..8c38f3f
--- /dev/null
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/app/media/apps.py b/app/media/apps.py
new file mode 100644 (file)
index 0000000..c36a53e
--- /dev/null
@@ -0,0 +1,7 @@
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class MediaConfig(AppConfig):
+    name = 'media'
diff --git a/app/media/migrations/__init__.py b/app/media/migrations/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/app/media/models.py b/app/media/models.py
new file mode 100644 (file)
index 0000000..3e1ad39
--- /dev/null
@@ -0,0 +1,28 @@
+from __future__ import unicode_literals
+
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+from mezzanine.core.models import RichText, Displayable, Slugged
+from mezzanine.core.fields import RichTextField, OrderField, FileField
+from mezzanine.utils.models import AdminThumbMixin, upload_to
+
+ALIGNMENT_CHOICES = (('left', _('left')), ('center', _('center')), ('right', _('right')))
+
+
+class Photos(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
diff --git a/app/media/tests.py b/app/media/tests.py
new file mode 100644 (file)
index 0000000..7ce503c
--- /dev/null
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/app/media/views.py b/app/media/views.py
new file mode 100644 (file)
index 0000000..91ea44a
--- /dev/null
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
index 9cb61db8d7e1ed79f606555618779d9c1811094b..20d1465bf4f72c1292e1b9d6a6fca83ed81a8df1 100644 (file)
@@ -21,6 +21,7 @@ from mezzanine.utils.models import AdminThumbMixin, upload_to
 
 from django_countries.fields import CountryField
 
+from media.models import Photos
 
 # Hack to have these strings translated
 mr = _('Mr')
@@ -40,8 +41,8 @@ TITLE_CHOICES = [
 ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right')))
 
 
-class NameMixin(models.Model):
-    """Base object with name and description"""
+class Named(models.Model):
+    """Named object with description"""
 
     name = models.CharField(_('name'), max_length=512)
     description = models.TextField(_('description'), blank=True)
@@ -71,7 +72,7 @@ class AddressMixin(models.Model):
             abstract = True
 
 
-class Organization(NameMixin, AddressMixin):
+class Organization(Named, AddressMixin):
     """(Organization description)"""
 
     type = models.ForeignKey('OrganizationType', verbose_name=_('organization type'), blank=True, null=True, on_delete=models.SET_NULL)
@@ -84,14 +85,14 @@ class Organization(NameMixin, AddressMixin):
         verbose_name = _('organization')
 
 
-class OrganizationType(NameMixin):
+class OrganizationType(Named):
     """(OrganizationType description)"""
 
     class Meta:
         verbose_name = _('organization type')
 
 
-class Department(NameMixin):
+class Department(Named):
     """(Department description)"""
 
     organization = models.ForeignKey('Organization', verbose_name=_('organization'))
@@ -105,7 +106,7 @@ class Department(NameMixin):
         verbose_name = _('department')
 
 
-class Team(NameMixin):
+class Team(Named):
     """(Team description)"""
 
     department = models.ForeignKey('Department', verbose_name=_('department'), blank=True, null=True, on_delete=models.SET_NULL)
@@ -114,7 +115,7 @@ class Team(NameMixin):
         return u"Team"
 
 
-class Person(Displayable, RichText, AdminThumbMixin):
+class Person(Displayable, RichText, AdminThumbMixin, Photos):
     """(Person description)"""
 
     user = models.ForeignKey(User, verbose_name=_('user'), blank=True, null=True, on_delete=models.SET_NULL)
@@ -125,14 +126,6 @@ class Person(Displayable, RichText, AdminThumbMixin):
     birthday = models.DateField(_('birthday'), blank=True)
     organization = models.ForeignKey('Organization', verbose_name=_('organization'), blank=True, null=True, on_delete=models.SET_NULL)
 
-    bio = RichTextField(_('biography'), blank=True)
-    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_featured = FileField(_('photo featured'), upload_to='images/photos', max_length=1024, blank=True, format="Image")
-    photo_featured_credits = models.CharField(_('photo featured credits'), max_length=255, blank=True, null=True)
-
     def __unicode__(self):
         return ' '.join((self.user.first_name, self.user.last_name))