from mezzanine.core.models import Displayable, Slugged
+COLOR_CHOICES = (('black', _('black')), ('yellow', _('yellow')), ('red', _('red')))
+
+
class Description(models.Model):
- """Base object description"""
+ """Abstract model providing a description field"""
description = models.TextField(_('description'), blank=True)
abstract = True
-class Named(Description):
- """Named object with description"""
+class Named(models.Model):
+ """Abstract model providing a name field"""
name = models.CharField(_('name'), max_length=512)
return slugify(self.__unicode__())
-class Titled(Slugged, Description):
- """Base object with title, slug and description"""
+class Titled(models.Model):
+ """Abstract model providing a title field"""
+
+ title = models.CharField(_('name'), max_length=1024)
class Meta:
abstract = True
+ def __str__(self):
+ return self.title
+
class SubTitle(models.Model):
abstract = True
-class BasicPage(Page, RichText, SubTitle):
+class Category(Named):
+ """Category description)"""
+
+ class Meta:
+ verbose_name = _('category')
+
+ def __str__(self):
+ return self.name
+
+
+class BasicPage(Page, SubTitle, RichText):
class Meta:
verbose_name = 'basic page'
+
+
+class PageBlock(Titled, RichText):
+
+ background_color = models.CharField(_('background color'), max_length=32, choices=COLOR_CHOICES, blank=True)
+
+ class Meta:
+ verbose_name = 'page block'
from django.conf import settings
from django.contrib.auth.models import User
+from mezzanine.pages.models import Page
from mezzanine.core.models import RichText, Displayable, Slugged
from mezzanine.core.fields import RichTextField, OrderField, FileField
from mezzanine.utils.models import AdminThumbMixin, upload_to
from organization.media.models import Photo
-from organization.core.models import Named, Titled
+from organization.core.models import Named, Titled, Description, SubTitle
from django_countries.fields import CountryField
-from .nationalities.fields import NationalityField
+# from .nationalities.fields import NationalityField
# Hack to have these strings translated
('Prof Dr', _('Prof Dr')),
]
-ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right')))
-
+ALIGNMENT_CHOICES = (('left', _('left')), ('left', _('left')), ('right', _('right')))
class Address(models.Model):
abstract = True
-class Organization(Titled, Address, Photo):
+class Organization(Slugged, Description, Address, Photo):
"""(Organization description)"""
type = models.ForeignKey('OrganizationType', verbose_name=_('organization type'), blank=True, null=True, on_delete=models.SET_NULL)
verbose_name = _('organization type')
-class Department(Titled):
+class Department(Page, SubTitle, RichText):
"""(Department description)"""
organization = models.ForeignKey('Organization', verbose_name=_('organization'))
verbose_name = _('department')
-class Team(Titled):
+class Team(Page, SubTitle, RichText):
"""(Team description)"""
- department = models.ForeignKey('Department', verbose_name=_('department'), blank=True, null=True, on_delete=models.SET_NULL)
+ # department = models.ForeignKey('Department', verbose_name=_('department'), related_name="teams", blank=True, null=True, on_delete=models.SET_NULL)
partner_organizations = models.ManyToManyField(Organization, verbose_name=_('partner organizations'), blank=True)
partner_teams = models.ManyToManyField('Team', verbose_name=_('partner teams'), blank=True)
verbose_name = _('team')
-class Person(AdminThumbMixin, Photo):
+class Person(Displayable, AdminThumbMixin, Photo):
"""(Person description)"""
user = models.ForeignKey(User, verbose_name=_('user'), blank=True, null=True, on_delete=models.SET_NULL)
- title = models.CharField(_('title'), max_length=16, choices=TITLE_CHOICES, blank=True)
+ person_title = models.CharField(_('title'), max_length=16, choices=TITLE_CHOICES, blank=True)
gender = models.CharField(_('gender'), max_length=16, choices=GENDER_CHOICES, blank=True)
first_name = models.CharField(_('first name'), max_length=255, blank=True, null=True)
last_name = models.CharField(_('last name'), max_length=255, blank=True, null=True)