from mezzanine.pages.models import Page, RichText
from mezzanine.core.fields import RichTextField, OrderField, FileField
+from mezzanine.core.models import Displayable, Slugged
-class Named(models.Model):
+class Description(models.Model):
+ """Base object description"""
+
+ description = models.TextField(_('description'), blank=True)
+
+ class Meta:
+ abstract = True
+
+
+class Named(Description):
"""Named object with description"""
name = models.CharField(_('name'), max_length=512)
- description = models.TextField(_('description'), blank=True)
-
+
class Meta:
abstract = True
- def __unicode__(self):
+ def __str__(self):
return self.name
@property
return slugify(self.__unicode__())
-class Titled(models.Model):
- """Base object with title and description"""
-
- title = models.CharField(_('title'), max_length=512)
- description = models.TextField(_('description'), blank=True)
+class Titled(Slugged, Description):
+ """Base object with title, slug and description"""
class Meta:
abstract = True
- def __unicode__(self):
- return self.title
-
class SubTitle(models.Model):
class PlaylistAdmin(admin.ModelAdmin):
model = Playlist
- list_display = ('__unicode__',)
+ list_display = ('__str__',)
filter_horizontal = ['audios']
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-21 11:51
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('sites', '0002_alter_domain_unique'),
+ ('organization-media', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='playlist',
+ name='site',
+ field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='playlist',
+ name='slug',
+ field=models.CharField(blank=True, help_text='Leave blank to have the URL auto-generated from the title.', max_length=2000, null=True, verbose_name='URL'),
+ ),
+ migrations.AlterField(
+ model_name='playlist',
+ name='title',
+ field=models.CharField(max_length=500, verbose_name='Title'),
+ ),
+ ]
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-21 11:51
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('sites', '0002_alter_domain_unique'),
+ ('organization-team', '0006_auto_20160720_2136'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='department',
+ name='name',
+ ),
+ migrations.RemoveField(
+ model_name='department',
+ name='name_en',
+ ),
+ migrations.RemoveField(
+ model_name='department',
+ name='name_fr',
+ ),
+ migrations.RemoveField(
+ model_name='organization',
+ name='name',
+ ),
+ migrations.RemoveField(
+ model_name='team',
+ name='name',
+ ),
+ migrations.RemoveField(
+ model_name='team',
+ name='name_en',
+ ),
+ migrations.RemoveField(
+ model_name='team',
+ name='name_fr',
+ ),
+ migrations.AddField(
+ model_name='department',
+ name='site',
+ field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='department',
+ name='slug',
+ field=models.CharField(blank=True, help_text='Leave blank to have the URL auto-generated from the title.', max_length=2000, null=True, verbose_name='URL'),
+ ),
+ migrations.AddField(
+ model_name='department',
+ name='title',
+ field=models.CharField(default='', max_length=500, verbose_name='Title'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='department',
+ name='title_en',
+ field=models.CharField(max_length=500, null=True, verbose_name='Title'),
+ ),
+ migrations.AddField(
+ model_name='department',
+ name='title_fr',
+ field=models.CharField(max_length=500, null=True, verbose_name='Title'),
+ ),
+ migrations.AddField(
+ model_name='organization',
+ name='site',
+ field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='organization',
+ name='slug',
+ field=models.CharField(blank=True, help_text='Leave blank to have the URL auto-generated from the title.', max_length=2000, null=True, verbose_name='URL'),
+ ),
+ migrations.AddField(
+ model_name='organization',
+ name='title',
+ field=models.CharField(default='', max_length=500, verbose_name='Title'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='team',
+ name='site',
+ field=models.ForeignKey(default=1, editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='team',
+ name='slug',
+ field=models.CharField(blank=True, help_text='Leave blank to have the URL auto-generated from the title.', max_length=2000, null=True, verbose_name='URL'),
+ ),
+ migrations.AddField(
+ model_name='team',
+ name='title',
+ field=models.CharField(default='', max_length=500, verbose_name='Title'),
+ preserve_default=False,
+ ),
+ migrations.AddField(
+ model_name='team',
+ name='title_en',
+ field=models.CharField(max_length=500, null=True, verbose_name='Title'),
+ ),
+ migrations.AddField(
+ model_name='team',
+ name='title_fr',
+ field=models.CharField(max_length=500, null=True, verbose_name='Title'),
+ ),
+ ]
from mezzanine.utils.models import AdminThumbMixin, upload_to
from organization.media.models import Photo
-from organization.core.models import Named
+from organization.core.models import Named, Titled
from django_countries.fields import CountryField
from .nationalities.fields import NationalityField
postal_code = models.CharField(_('postal code'), max_length=16, blank=True)
country = CountryField(_('country'))
- def __unicode__(self):
- return u"Address"
+ def __str__(self):
+ return ' '.join((self.address, self.postal_code, self.country))
class Meta:
abstract = True
-class Organization(Named, Address, Photo):
+class Organization(Titled, Address, Photo):
"""(Organization description)"""
type = models.ForeignKey('OrganizationType', verbose_name=_('organization type'), blank=True, null=True, on_delete=models.SET_NULL)
url = models.URLField(_('URL'), max_length=512, blank=True)
is_on_map = models.BooleanField(_('is on map'), default=True)
- def __unicode__(self):
- return self.name
-
class Meta:
verbose_name = _('organization')
verbose_name = _('organization type')
-class Department(Named):
+class Department(Titled):
"""(Department description)"""
organization = models.ForeignKey('Organization', verbose_name=_('organization'))
url = models.URLField(_('URL'), max_length=512, blank=True)
weaving_css_class = models.CharField(_('weaving CSS class'), max_length=64, blank=True)
- def __unicode__(self):
- return self.name
-
class Meta:
verbose_name = _('department')
-class Team(Named):
+class Team(Titled):
"""(Team description)"""
department = models.ForeignKey('Department', verbose_name=_('department'), blank=True, null=True, on_delete=models.SET_NULL)
class Meta:
verbose_name = _('team')
- def __unicode__(self):
- return self.name
-
class Person(AdminThumbMixin, Photo):
"""(Person description)"""
@register(Department)
class DepartmentTranslationOptions(TranslationOptions):
- fields = ('name', 'description',)
+ fields = ('title', 'description',)
@register(Team)
class TeamTranslationOptions(TranslationOptions):
- fields = ('name', 'description',)
+ fields = ('title', 'description',)
@register(Person)