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'
--- /dev/null
+from django.contrib import admin
+
+# Register your models here.
--- /dev/null
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class MediaConfig(AppConfig):
+ name = 'media'
--- /dev/null
+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
--- /dev/null
+from django.test import TestCase
+
+# Create your tests here.
--- /dev/null
+from django.shortcuts import render
+
+# Create your views here.
from django_countries.fields import CountryField
+from media.models import Photos
# Hack to have these strings translated
mr = _('Mr')
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)
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)
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'))
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)
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)
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))