From: Guillaume Pellerin Date: Thu, 7 Jul 2016 16:28:39 +0000 (+0200) Subject: add urls to each module X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=9aae45af4bc7946650391e9a15b25ec00052c6a5;p=mezzo.git add urls to each module --- diff --git a/app/local_settings.py b/app/local_settings.py index fdf1d784..96e92ada 100644 --- a/app/local_settings.py +++ b/app/local_settings.py @@ -72,9 +72,9 @@ ADMIN_MENU_ORDER = ( (_('Content'), ('pages.Page', 'blog.BlogPost', 'mezzanine_agenda.Event', 'generic.ThreadedComment', (_('Media Library'), 'fb_browse'),)), (_("Magazine"), ("magazine.Article",)), - (_('Structure'), ('organization.structure.Organization', 'organization.structure.Team', - 'organization.structure.Department', 'organization.structure.Person', - 'organization.structure.Activity')), + (_('team'), ('organization.team.Organization', 'organization.team.Team', + 'organization.team.Department', 'organization.team.Person', + 'organization.team.Activity')), (_('Projects'), ('organization.project.Project')), (_('Festival'), ('organization.festival.Artist', 'organization.festival.Video', 'organization.festival.Audio', 'organization.festival.Playlist', diff --git a/app/organization/core/urls.py b/app/organization/core/urls.py new file mode 100644 index 00000000..68af3c40 --- /dev/null +++ b/app/organization/core/urls.py @@ -0,0 +1,15 @@ +from __future__ import unicode_literals + +import django.views.i18n +from django.conf.urls import patterns, include, url +from django.conf.urls.i18n import i18n_patterns + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + +from organization.core.views import HomeView + + +urlpatterns = [ + url("^$", HomeView.as_view(), name="home"), +] diff --git a/app/organization/core/views.py b/app/organization/core/views.py index 34f51cd6..82dc1b0c 100644 --- a/app/organization/core/views.py +++ b/app/organization/core/views.py @@ -1,4 +1,7 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 +from django.http import Http404 +from django.views.generic.base import View +from django.views.generic import DetailView, ListView, TemplateView class SlugMixin(object): @@ -6,3 +9,12 @@ class SlugMixin(object): def get_object(self): objects = self.model.objects.all() return get_object_or_404(objects, slug=self.kwargs['slug']) + + +class HomeView(TemplateView): + + template_name = 'index.html' + + def get_context_data(self, **kwargs): + context = super(HomeView, self).get_context_data(**kwargs) + return context diff --git a/app/organization/featured/urls.py b/app/organization/featured/urls.py new file mode 100644 index 00000000..cea975ae --- /dev/null +++ b/app/organization/featured/urls.py @@ -0,0 +1,13 @@ +from __future__ import unicode_literals + +import django.views.i18n +from django.conf.urls import patterns, include, url +from django.conf.urls.i18n import i18n_patterns + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + + +urlpatterns = [ + +] diff --git a/app/organization/festival/urls.py b/app/organization/festival/urls.py index 920e5eff..c13eedb4 100644 --- a/app/organization/festival/urls.py +++ b/app/organization/festival/urls.py @@ -1,8 +1,8 @@ from __future__ import unicode_literals +import django.views.i18n from django.conf.urls import patterns, include, url from django.conf.urls.i18n import i18n_patterns -from django.contrib import admin from mezzanine.core.views import direct_to_template from mezzanine.conf import settings diff --git a/app/organization/magazine/urls.py b/app/organization/magazine/urls.py new file mode 100644 index 00000000..cea975ae --- /dev/null +++ b/app/organization/magazine/urls.py @@ -0,0 +1,13 @@ +from __future__ import unicode_literals + +import django.views.i18n +from django.conf.urls import patterns, include, url +from django.conf.urls.i18n import i18n_patterns + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + + +urlpatterns = [ + +] diff --git a/app/organization/media/urls.py b/app/organization/media/urls.py index 50ba7290..4b0faa6a 100644 --- a/app/organization/media/urls.py +++ b/app/organization/media/urls.py @@ -1,13 +1,13 @@ from __future__ import unicode_literals +import django.views.i18n from django.conf.urls import patterns, include, url from django.conf.urls.i18n import i18n_patterns -from django.contrib import admin from mezzanine.core.views import direct_to_template from mezzanine.conf import settings -from organization.festival.views import * +from organization.media.views import * urlpatterns = [ diff --git a/app/organization/project/migrations/0002_auto_20160707_1053.py b/app/organization/project/migrations/0002_auto_20160707_1053.py index 59768c53..5d78ef15 100644 --- a/app/organization/project/migrations/0002_auto_20160707_1053.py +++ b/app/organization/project/migrations/0002_auto_20160707_1053.py @@ -13,19 +13,19 @@ class Migration(migrations.Migration): dependencies = [ ('sites', '0002_alter_domain_unique'), ('organization project', '0001_initial'), - ('organization structure', '0001_initial'), + ('organization team', '0001_initial'), ] operations = [ migrations.AddField( model_name='project', name='partners', - field=models.ManyToManyField(to='organization structure.Organization', verbose_name='organizations'), + field=models.ManyToManyField(to='organization team.Organization', verbose_name='organizations'), ), migrations.AddField( model_name='project', name='persons', - field=models.ManyToManyField(to='organization structure.Person', verbose_name='persons'), + field=models.ManyToManyField(to='organization team.Person', verbose_name='persons'), ), migrations.AddField( model_name='project', diff --git a/app/organization/project/models.py b/app/organization/project/models.py index 34f61d21..31a7792d 100644 --- a/app/organization/project/models.py +++ b/app/organization/project/models.py @@ -5,7 +5,7 @@ from django.utils.translation import ugettext_lazy as _ from mezzanine.core.models import RichText, Displayable, Slugged -from organization.structure.models import Person, Organization +from organization.team.models import Person, Organization class Project(Displayable, RichText): diff --git a/app/organization/project/urls.py b/app/organization/project/urls.py new file mode 100644 index 00000000..cea975ae --- /dev/null +++ b/app/organization/project/urls.py @@ -0,0 +1,13 @@ +from __future__ import unicode_literals + +import django.views.i18n +from django.conf.urls import patterns, include, url +from django.conf.urls.i18n import i18n_patterns + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + + +urlpatterns = [ + +] diff --git a/app/organization/structure/__init__.py b/app/organization/structure/__init__.py deleted file mode 100644 index 64cb6f58..00000000 --- a/app/organization/structure/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Provides abstract models and admin features used throughout the various -Mezzanine apps. -""" -from __future__ import unicode_literals - -from mezzanine import __version__ # noqa - - -default_app_config = 'organization.structure.apps.StructureConfig' diff --git a/app/organization/structure/admin.py b/app/organization/structure/admin.py deleted file mode 100644 index 8c38f3f3..00000000 --- a/app/organization/structure/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/app/organization/structure/apps.py b/app/organization/structure/apps.py deleted file mode 100644 index 671fe585..00000000 --- a/app/organization/structure/apps.py +++ /dev/null @@ -1,9 +0,0 @@ -from __future__ import unicode_literals - -from django.apps import AppConfig - - -class StructureConfig(AppConfig): - - name = 'organization.structure' - label = 'organization structure' diff --git a/app/organization/structure/migrations/0001_initial.py b/app/organization/structure/migrations/0001_initial.py deleted file mode 100644 index eb6a618d..00000000 --- a/app/organization/structure/migrations/0001_initial.py +++ /dev/null @@ -1,193 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-07-07 08:53 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import django_countries.fields -import mezzanine.core.fields -import mezzanine.utils.models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('sites', '0002_alter_domain_unique'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Activity', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('date_begin', models.DateField(blank=True, null=True, verbose_name='begin date')), - ('date_end', models.DateField(blank=True, null=True, verbose_name='end date')), - ('role', models.CharField(blank=True, max_length=512, verbose_name='role')), - ('work', models.TextField(blank=True, verbose_name='work')), - ], - ), - migrations.CreateModel( - name='Address', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('address', models.TextField(blank=True, verbose_name='description')), - ('postal_code', models.CharField(blank=True, max_length=16, verbose_name='postal code')), - ('country', django_countries.fields.CountryField(max_length=2, verbose_name='country')), - ], - ), - migrations.CreateModel( - name='Department', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=512, verbose_name='name')), - ('description', models.TextField(blank=True, verbose_name='description')), - ('url', models.URLField(blank=True, max_length=512, verbose_name='URL')), - ('weaving_class', models.CharField(blank=True, max_length=64, verbose_name='weaving class')), - ], - options={ - 'verbose_name': 'department', - }, - ), - migrations.CreateModel( - name='Link', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('url', models.URLField(verbose_name='URL')), - ], - ), - migrations.CreateModel( - name='LinkType', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=256, verbose_name='Name')), - ('slug', models.SlugField(blank=True, help_text='Use this field to define a simple identifier that can be used to style the different link types (i.e. assign social media icons to them)', max_length=256, verbose_name='Slug')), - ('ordering', models.PositiveIntegerField(blank=True, null=True, verbose_name='Ordering')), - ], - options={ - 'ordering': ['ordering'], - }, - ), - migrations.CreateModel( - name='Modelname', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ], - ), - migrations.CreateModel( - name='Nationality', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=128, verbose_name='name')), - ], - ), - migrations.CreateModel( - name='OrganizationType', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=512, verbose_name='name')), - ('description', models.TextField(blank=True, verbose_name='description')), - ], - options={ - 'verbose_name': 'organization type', - }, - ), - migrations.CreateModel( - name='Person', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('keywords_string', models.CharField(blank=True, editable=False, max_length=500)), - ('title', models.CharField(max_length=500, verbose_name='Title')), - ('slug', 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')), - ('_meta_title', models.CharField(blank=True, help_text='Optional title to be used in the HTML title tag. If left blank, the main title field will be used.', max_length=500, null=True, verbose_name='Title')), - ('description', models.TextField(blank=True, verbose_name='Description')), - ('gen_description', models.BooleanField(default=True, help_text='If checked, the description will be automatically generated from content. Uncheck if you want to manually set a custom description.', verbose_name='Generate description')), - ('created', models.DateTimeField(editable=False, null=True)), - ('updated', models.DateTimeField(editable=False, null=True)), - ('status', models.IntegerField(choices=[(1, 'Draft'), (2, 'Published')], default=2, help_text='With Draft chosen, will only be shown for admin users on the site.', verbose_name='Status')), - ('publish_date', models.DateTimeField(blank=True, db_index=True, help_text="With Published chosen, won't be shown until this time", null=True, verbose_name='Published from')), - ('expiry_date', models.DateTimeField(blank=True, help_text="With Published chosen, won't be shown after this time", null=True, verbose_name='Expires on')), - ('short_url', models.URLField(blank=True, null=True)), - ('in_sitemap', models.BooleanField(default=True, verbose_name='Show in sitemap')), - ('content', mezzanine.core.fields.RichTextField(verbose_name='Content')), - ('photo', mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='photo')), - ('photo_credits', models.CharField(blank=True, max_length=255, null=True, verbose_name='photo credits')), - ('photo_alignment', models.CharField(blank=True, choices=[('left', 'left'), ('center', 'center'), ('right', 'right')], default='left', max_length=32, verbose_name='photo alignment')), - ('photo_description', models.TextField(blank=True, verbose_name='photo description')), - ('photo_card', mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='card photo')), - ('photo_card_credits', models.CharField(blank=True, max_length=255, null=True, verbose_name='photo card credits')), - ('photo_slider', mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='slider photo')), - ('photo_slider_credits', models.CharField(blank=True, max_length=255, null=True, verbose_name='photo slider credits')), - ('person_title', models.CharField(blank=True, choices=[('Dr', 'Dr'), ('Prof', 'Prof'), ('Prof Dr', 'Prof Dr')], max_length=16, verbose_name='title')), - ('gender', models.CharField(blank=True, choices=[('male', 'male'), ('female', 'female')], max_length=16, verbose_name='gender')), - ('first_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='first name')), - ('last_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='last name')), - ('birthday', models.DateField(blank=True, verbose_name='birthday')), - ('site', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site')), - ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='user')), - ], - options={ - 'abstract': False, - }, - bases=(mezzanine.utils.models.AdminThumbMixin, models.Model), - ), - migrations.CreateModel( - name='Team', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=512, verbose_name='name')), - ('description', models.TextField(blank=True, verbose_name='description')), - ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='organization structure.Department', verbose_name='department')), - ], - options={ - 'abstract': False, - }, - ), - migrations.CreateModel( - name='Organization', - fields=[ - ('address_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='organization structure.Address')), - ('name', models.CharField(max_length=512, verbose_name='name')), - ('description', models.TextField(blank=True, verbose_name='description')), - ('url', models.URLField(blank=True, max_length=512, verbose_name='URL')), - ('type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='organization structure.OrganizationType', verbose_name='organization type')), - ], - options={ - 'verbose_name': 'organization', - }, - bases=('organization structure.address', models.Model), - ), - migrations.AddField( - model_name='link', - name='link_type', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization structure.LinkType', verbose_name='Link type'), - ), - migrations.AddField( - model_name='link', - name='person', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization structure.Person', verbose_name='Person'), - ), - migrations.AddField( - model_name='activity', - name='person', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization structure.Person', verbose_name='person'), - ), - migrations.AddField( - model_name='activity', - name='teams', - field=models.ManyToManyField(to='organization structure.Team', verbose_name='teams'), - ), - migrations.AddField( - model_name='person', - name='organization', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='organization structure.Organization', verbose_name='organization'), - ), - migrations.AddField( - model_name='department', - name='organization', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization structure.Organization', verbose_name='organization'), - ), - ] diff --git a/app/organization/structure/migrations/0002_auto_20160707_1614.py b/app/organization/structure/migrations/0002_auto_20160707_1614.py deleted file mode 100644 index 07f60e12..00000000 --- a/app/organization/structure/migrations/0002_auto_20160707_1614.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-07-07 14:14 -from __future__ import unicode_literals - -from django.db import migrations -import mezzanine.core.fields - - -class Migration(migrations.Migration): - - dependencies = [ - ('organization structure', '0001_initial'), - ] - - operations = [ - migrations.DeleteModel( - name='Modelname', - ), - migrations.AlterModelOptions( - name='person', - options={'ordering': ['last_name'], 'verbose_name': 'person'}, - ), - migrations.AddField( - model_name='person', - name='bio', - field=mezzanine.core.fields.RichTextField(blank=True, verbose_name='biography'), - ), - ] diff --git a/app/organization/structure/migrations/__init__.py b/app/organization/structure/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/app/organization/structure/models.py b/app/organization/structure/models.py deleted file mode 100644 index 139ccfe1..00000000 --- a/app/organization/structure/models.py +++ /dev/null @@ -1,202 +0,0 @@ -from __future__ import unicode_literals - -import os -import re -import pwd -import time -import urllib -import string -import datetime -import mimetypes - -from django.db import models -from django.utils.translation import ugettext_lazy as _ -from django.core.urlresolvers import reverse, reverse_lazy -from django.conf import settings -from django.contrib.auth.models import User - -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 django_countries.fields import CountryField - -from organization.media.models import Photo -from organization.core.models import Named - -# Hack to have these strings translated -mr = _('Mr') -mrs = _('Ms') - -GENDER_CHOICES = [ - ('male', _('male')), - ('female', _('female')), -] - -TITLE_CHOICES = [ - ('Dr', _('Dr')), - ('Prof', _('Prof')), - ('Prof Dr', _('Prof Dr')), -] - -ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right'))) - - - -class Address(models.Model): - """(Address description)""" - - address = models.TextField(_('description'), blank=True) - postal_code = models.CharField(_('postal code'), max_length=16, blank=True) - country = CountryField(_('country')) - - def __unicode__(self): - return u"Address" - - class Meta: - abstract = True - - -class Organization(Named, Address): - """(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) - - def __unicode__(self): - return self.name - - class Meta: - verbose_name = _('organization') - - -class OrganizationType(Named): - """(OrganizationType description)""" - - class Meta: - verbose_name = _('organization type') - - -class Department(Named): - """(Department description)""" - - organization = models.ForeignKey('Organization', verbose_name=_('organization')) - url = models.URLField(_('URL'), max_length=512, blank=True) - weaving_class = models.CharField(_('weaving class'), max_length=64, blank=True) - - def __unicode__(self): - return self.name - - class Meta: - verbose_name = _('department') - - -class Team(Named): - """(Team description)""" - - department = models.ForeignKey('Department', verbose_name=_('department'), blank=True, null=True, on_delete=models.SET_NULL) - - def __unicode__(self): - return u"Team" - - -class Person(Displayable, RichText, AdminThumbMixin, Photo): - """(Person description)""" - - user = models.ForeignKey(User, verbose_name=_('user'), blank=True, null=True, on_delete=models.SET_NULL) - 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) - 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) - - class Meta: - verbose_name = _('person') - ordering = ['last_name',] - - def __unicode__(self): - return ' '.join((self.user.first_name, self.user.last_name)) - - # def get_absolute_url(self): - # return reverse("festival-artist-detail", kwargs={'slug': self.slug}) - - def set_names(self): - names = self.title.split(' ') - if len(names) == 1: - self.first_name = '' - self.last_name = names[0] - elif len(names) == 2: - self.first_name = names[0] - self.last_name = names[1] - else: - self.first_name = names[0] - self.last_name = ' '.join(names[1:]) - - def clean(self): - super(Person, self).clean() - self.set_names() - - def save(self, *args, **kwargs): - self.set_names() - super(Person, self).save(*args, **kwargs) - - -class Nationality(models.Model): - """(Nationality description)""" - - name = models.CharField(_('name'), max_length=128) - - def __unicode__(self): - return self.name - - -class Link(models.Model): - """A person can have many links.""" - - person = models.ForeignKey('Person', verbose_name=_('Person')) - link_type = models.ForeignKey('LinkType', verbose_name=_('Link type')) - url = models.URLField(verbose_name=_('URL')) - - def __str__(self): - return self.url - - -class LinkType(models.Model): - """ - A link type could be ``Facebook`` or ``Twitter`` or ``Website``. - This is masterdata that should be created by the admins when the site is - deployed for the first time. - :ordering: Enter numbers here if you want links to be displayed in a - special order. - """ - - name = models.CharField(max_length=256, verbose_name=_('Name')) - slug = models.SlugField(max_length=256, verbose_name=_('Slug'), help_text=_( - 'Use this field to define a simple identifier that can be used' - ' to style the different link types (i.e. assign social media' - ' icons to them)'), - blank=True, - ) - ordering = models.PositiveIntegerField(verbose_name=_('Ordering'), null=True, blank=True) - - class Meta: - ordering = ['ordering', ] - - def __str__(self): - return self.name - - -class Activity(models.Model): - """(Activity description)""" - - person = models.ForeignKey('Person', verbose_name=_('person')) - teams = models.ManyToManyField('Team', verbose_name=_('teams')) - date_begin = models.DateField(_('begin date'), null=True, blank=True) - date_end = models.DateField(_('end date'), null=True, blank=True) - role = models.CharField(_('role'), blank=True, max_length=512) - work = models.TextField(_('work'), blank=True) - - def __unicode__(self): - return ' - '.join((self.person, self.role, self.date_begin, self.date_end)) diff --git a/app/organization/structure/tests.py b/app/organization/structure/tests.py deleted file mode 100644 index 7ce503c2..00000000 --- a/app/organization/structure/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/app/organization/structure/views.py b/app/organization/structure/views.py deleted file mode 100644 index 91ea44a2..00000000 --- a/app/organization/structure/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/app/organization/team/__init__.py b/app/organization/team/__init__.py new file mode 100644 index 00000000..2de9352f --- /dev/null +++ b/app/organization/team/__init__.py @@ -0,0 +1,10 @@ +""" +Provides abstract models and admin features used throughout the various +Mezzanine apps. +""" +from __future__ import unicode_literals + +from mezzanine import __version__ # noqa + + +default_app_config = 'organization.team.apps.teamConfig' diff --git a/app/organization/team/admin.py b/app/organization/team/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/app/organization/team/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/organization/team/apps.py b/app/organization/team/apps.py new file mode 100644 index 00000000..81f7caf5 --- /dev/null +++ b/app/organization/team/apps.py @@ -0,0 +1,9 @@ +from __future__ import unicode_literals + +from django.apps import AppConfig + + +class teamConfig(AppConfig): + + name = 'organization.team' + label = 'organization team' diff --git a/app/organization/team/migrations/0001_initial.py b/app/organization/team/migrations/0001_initial.py new file mode 100644 index 00000000..4b4382b0 --- /dev/null +++ b/app/organization/team/migrations/0001_initial.py @@ -0,0 +1,193 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-07 08:53 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django_countries.fields +import mezzanine.core.fields +import mezzanine.utils.models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('sites', '0002_alter_domain_unique'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Activity', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date_begin', models.DateField(blank=True, null=True, verbose_name='begin date')), + ('date_end', models.DateField(blank=True, null=True, verbose_name='end date')), + ('role', models.CharField(blank=True, max_length=512, verbose_name='role')), + ('work', models.TextField(blank=True, verbose_name='work')), + ], + ), + migrations.CreateModel( + name='Address', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('address', models.TextField(blank=True, verbose_name='description')), + ('postal_code', models.CharField(blank=True, max_length=16, verbose_name='postal code')), + ('country', django_countries.fields.CountryField(max_length=2, verbose_name='country')), + ], + ), + migrations.CreateModel( + name='Department', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=512, verbose_name='name')), + ('description', models.TextField(blank=True, verbose_name='description')), + ('url', models.URLField(blank=True, max_length=512, verbose_name='URL')), + ('weaving_class', models.CharField(blank=True, max_length=64, verbose_name='weaving class')), + ], + options={ + 'verbose_name': 'department', + }, + ), + migrations.CreateModel( + name='Link', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('url', models.URLField(verbose_name='URL')), + ], + ), + migrations.CreateModel( + name='LinkType', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=256, verbose_name='Name')), + ('slug', models.SlugField(blank=True, help_text='Use this field to define a simple identifier that can be used to style the different link types (i.e. assign social media icons to them)', max_length=256, verbose_name='Slug')), + ('ordering', models.PositiveIntegerField(blank=True, null=True, verbose_name='Ordering')), + ], + options={ + 'ordering': ['ordering'], + }, + ), + migrations.CreateModel( + name='Modelname', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + migrations.CreateModel( + name='Nationality', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=128, verbose_name='name')), + ], + ), + migrations.CreateModel( + name='OrganizationType', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=512, verbose_name='name')), + ('description', models.TextField(blank=True, verbose_name='description')), + ], + options={ + 'verbose_name': 'organization type', + }, + ), + migrations.CreateModel( + name='Person', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('keywords_string', models.CharField(blank=True, editable=False, max_length=500)), + ('title', models.CharField(max_length=500, verbose_name='Title')), + ('slug', 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')), + ('_meta_title', models.CharField(blank=True, help_text='Optional title to be used in the HTML title tag. If left blank, the main title field will be used.', max_length=500, null=True, verbose_name='Title')), + ('description', models.TextField(blank=True, verbose_name='Description')), + ('gen_description', models.BooleanField(default=True, help_text='If checked, the description will be automatically generated from content. Uncheck if you want to manually set a custom description.', verbose_name='Generate description')), + ('created', models.DateTimeField(editable=False, null=True)), + ('updated', models.DateTimeField(editable=False, null=True)), + ('status', models.IntegerField(choices=[(1, 'Draft'), (2, 'Published')], default=2, help_text='With Draft chosen, will only be shown for admin users on the site.', verbose_name='Status')), + ('publish_date', models.DateTimeField(blank=True, db_index=True, help_text="With Published chosen, won't be shown until this time", null=True, verbose_name='Published from')), + ('expiry_date', models.DateTimeField(blank=True, help_text="With Published chosen, won't be shown after this time", null=True, verbose_name='Expires on')), + ('short_url', models.URLField(blank=True, null=True)), + ('in_sitemap', models.BooleanField(default=True, verbose_name='Show in sitemap')), + ('content', mezzanine.core.fields.RichTextField(verbose_name='Content')), + ('photo', mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='photo')), + ('photo_credits', models.CharField(blank=True, max_length=255, null=True, verbose_name='photo credits')), + ('photo_alignment', models.CharField(blank=True, choices=[('left', 'left'), ('center', 'center'), ('right', 'right')], default='left', max_length=32, verbose_name='photo alignment')), + ('photo_description', models.TextField(blank=True, verbose_name='photo description')), + ('photo_card', mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='card photo')), + ('photo_card_credits', models.CharField(blank=True, max_length=255, null=True, verbose_name='photo card credits')), + ('photo_slider', mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='slider photo')), + ('photo_slider_credits', models.CharField(blank=True, max_length=255, null=True, verbose_name='photo slider credits')), + ('person_title', models.CharField(blank=True, choices=[('Dr', 'Dr'), ('Prof', 'Prof'), ('Prof Dr', 'Prof Dr')], max_length=16, verbose_name='title')), + ('gender', models.CharField(blank=True, choices=[('male', 'male'), ('female', 'female')], max_length=16, verbose_name='gender')), + ('first_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=255, null=True, verbose_name='last name')), + ('birthday', models.DateField(blank=True, verbose_name='birthday')), + ('site', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='sites.Site')), + ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='user')), + ], + options={ + 'abstract': False, + }, + bases=(mezzanine.utils.models.AdminThumbMixin, models.Model), + ), + migrations.CreateModel( + name='Team', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=512, verbose_name='name')), + ('description', models.TextField(blank=True, verbose_name='description')), + ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='organization team.Department', verbose_name='department')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Organization', + fields=[ + ('address_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='organization team.Address')), + ('name', models.CharField(max_length=512, verbose_name='name')), + ('description', models.TextField(blank=True, verbose_name='description')), + ('url', models.URLField(blank=True, max_length=512, verbose_name='URL')), + ('type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='organization team.OrganizationType', verbose_name='organization type')), + ], + options={ + 'verbose_name': 'organization', + }, + bases=('organization team.address', models.Model), + ), + migrations.AddField( + model_name='link', + name='link_type', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization team.LinkType', verbose_name='Link type'), + ), + migrations.AddField( + model_name='link', + name='person', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization team.Person', verbose_name='Person'), + ), + migrations.AddField( + model_name='activity', + name='person', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization team.Person', verbose_name='person'), + ), + migrations.AddField( + model_name='activity', + name='teams', + field=models.ManyToManyField(to='organization team.Team', verbose_name='teams'), + ), + migrations.AddField( + model_name='person', + name='organization', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='organization team.Organization', verbose_name='organization'), + ), + migrations.AddField( + model_name='department', + name='organization', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization team.Organization', verbose_name='organization'), + ), + ] diff --git a/app/organization/team/migrations/0002_auto_20160707_1614.py b/app/organization/team/migrations/0002_auto_20160707_1614.py new file mode 100644 index 00000000..28aa1de8 --- /dev/null +++ b/app/organization/team/migrations/0002_auto_20160707_1614.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-07 14:14 +from __future__ import unicode_literals + +from django.db import migrations +import mezzanine.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization team', '0001_initial'), + ] + + operations = [ + migrations.DeleteModel( + name='Modelname', + ), + migrations.AlterModelOptions( + name='person', + options={'ordering': ['last_name'], 'verbose_name': 'person'}, + ), + migrations.AddField( + model_name='person', + name='bio', + field=mezzanine.core.fields.RichTextField(blank=True, verbose_name='biography'), + ), + ] diff --git a/app/organization/team/migrations/__init__.py b/app/organization/team/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/organization/team/models.py b/app/organization/team/models.py new file mode 100644 index 00000000..139ccfe1 --- /dev/null +++ b/app/organization/team/models.py @@ -0,0 +1,202 @@ +from __future__ import unicode_literals + +import os +import re +import pwd +import time +import urllib +import string +import datetime +import mimetypes + +from django.db import models +from django.utils.translation import ugettext_lazy as _ +from django.core.urlresolvers import reverse, reverse_lazy +from django.conf import settings +from django.contrib.auth.models import User + +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 django_countries.fields import CountryField + +from organization.media.models import Photo +from organization.core.models import Named + +# Hack to have these strings translated +mr = _('Mr') +mrs = _('Ms') + +GENDER_CHOICES = [ + ('male', _('male')), + ('female', _('female')), +] + +TITLE_CHOICES = [ + ('Dr', _('Dr')), + ('Prof', _('Prof')), + ('Prof Dr', _('Prof Dr')), +] + +ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right'))) + + + +class Address(models.Model): + """(Address description)""" + + address = models.TextField(_('description'), blank=True) + postal_code = models.CharField(_('postal code'), max_length=16, blank=True) + country = CountryField(_('country')) + + def __unicode__(self): + return u"Address" + + class Meta: + abstract = True + + +class Organization(Named, Address): + """(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) + + def __unicode__(self): + return self.name + + class Meta: + verbose_name = _('organization') + + +class OrganizationType(Named): + """(OrganizationType description)""" + + class Meta: + verbose_name = _('organization type') + + +class Department(Named): + """(Department description)""" + + organization = models.ForeignKey('Organization', verbose_name=_('organization')) + url = models.URLField(_('URL'), max_length=512, blank=True) + weaving_class = models.CharField(_('weaving class'), max_length=64, blank=True) + + def __unicode__(self): + return self.name + + class Meta: + verbose_name = _('department') + + +class Team(Named): + """(Team description)""" + + department = models.ForeignKey('Department', verbose_name=_('department'), blank=True, null=True, on_delete=models.SET_NULL) + + def __unicode__(self): + return u"Team" + + +class Person(Displayable, RichText, AdminThumbMixin, Photo): + """(Person description)""" + + user = models.ForeignKey(User, verbose_name=_('user'), blank=True, null=True, on_delete=models.SET_NULL) + 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) + 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) + + class Meta: + verbose_name = _('person') + ordering = ['last_name',] + + def __unicode__(self): + return ' '.join((self.user.first_name, self.user.last_name)) + + # def get_absolute_url(self): + # return reverse("festival-artist-detail", kwargs={'slug': self.slug}) + + def set_names(self): + names = self.title.split(' ') + if len(names) == 1: + self.first_name = '' + self.last_name = names[0] + elif len(names) == 2: + self.first_name = names[0] + self.last_name = names[1] + else: + self.first_name = names[0] + self.last_name = ' '.join(names[1:]) + + def clean(self): + super(Person, self).clean() + self.set_names() + + def save(self, *args, **kwargs): + self.set_names() + super(Person, self).save(*args, **kwargs) + + +class Nationality(models.Model): + """(Nationality description)""" + + name = models.CharField(_('name'), max_length=128) + + def __unicode__(self): + return self.name + + +class Link(models.Model): + """A person can have many links.""" + + person = models.ForeignKey('Person', verbose_name=_('Person')) + link_type = models.ForeignKey('LinkType', verbose_name=_('Link type')) + url = models.URLField(verbose_name=_('URL')) + + def __str__(self): + return self.url + + +class LinkType(models.Model): + """ + A link type could be ``Facebook`` or ``Twitter`` or ``Website``. + This is masterdata that should be created by the admins when the site is + deployed for the first time. + :ordering: Enter numbers here if you want links to be displayed in a + special order. + """ + + name = models.CharField(max_length=256, verbose_name=_('Name')) + slug = models.SlugField(max_length=256, verbose_name=_('Slug'), help_text=_( + 'Use this field to define a simple identifier that can be used' + ' to style the different link types (i.e. assign social media' + ' icons to them)'), + blank=True, + ) + ordering = models.PositiveIntegerField(verbose_name=_('Ordering'), null=True, blank=True) + + class Meta: + ordering = ['ordering', ] + + def __str__(self): + return self.name + + +class Activity(models.Model): + """(Activity description)""" + + person = models.ForeignKey('Person', verbose_name=_('person')) + teams = models.ManyToManyField('Team', verbose_name=_('teams')) + date_begin = models.DateField(_('begin date'), null=True, blank=True) + date_end = models.DateField(_('end date'), null=True, blank=True) + role = models.CharField(_('role'), blank=True, max_length=512) + work = models.TextField(_('work'), blank=True) + + def __unicode__(self): + return ' - '.join((self.person, self.role, self.date_begin, self.date_end)) diff --git a/app/organization/team/tests.py b/app/organization/team/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/app/organization/team/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/organization/team/urls.py b/app/organization/team/urls.py new file mode 100644 index 00000000..ace2c073 --- /dev/null +++ b/app/organization/team/urls.py @@ -0,0 +1,15 @@ +from __future__ import unicode_literals + +import django.views.i18n +from django.conf.urls import patterns, include, url +from django.conf.urls.i18n import i18n_patterns + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + +from organization.team.views import * + + +urlpatterns = [ + +] diff --git a/app/organization/team/views.py b/app/organization/team/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/app/organization/team/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/organization/urls.py b/app/organization/urls.py new file mode 100644 index 00000000..adafa016 --- /dev/null +++ b/app/organization/urls.py @@ -0,0 +1,21 @@ +from __future__ import unicode_literals + +import django.views.i18n +from django.conf.urls import patterns, include, url +from django.conf.urls.i18n import i18n_patterns +from django.contrib import admin + +admin.autodiscover() + +from mezzanine.core.views import direct_to_template +from mezzanine.conf import settings + + +urlpatterns = [ + url("^", include('organization.core.urls')), + url("^festival/", include('organization.festival.urls')), + url("^magazine/", include('organization.magazine.urls')), + url("^media/", include('organization.media.urls')), + url("^project/", include('organization.project.urls')), + url("^team/", include('organization.team.urls')), +] diff --git a/app/settings.py b/app/settings.py index 04e094b7..788d0eba 100644 --- a/app/settings.py +++ b/app/settings.py @@ -219,7 +219,7 @@ INSTALLED_APPS = [ "meta", "mezzanine_agenda", "organization.core", - "organization.structure", + "organization.team", "organization.festival", "organization.magazine", "organization.media", diff --git a/app/urls.py b/app/urls.py index 10df47eb..6e0a5d17 100644 --- a/app/urls.py +++ b/app/urls.py @@ -27,8 +27,11 @@ if settings.USE_MODELTRANSLATION: urlpatterns += [ - url(r'^festival/', include('organization.festival.urls')), + # App urls + + url("^", include('organization.urls')), url("^%s/" % settings.EVENT_SLUG, include("mezzanine_agenda.urls")), + url("^styles/$", direct_to_template, {"template": "styles.html"}, name="styles"), # We don't want to presume how your homepage works, so here are a # few patterns you can use to set it up. @@ -40,8 +43,7 @@ urlpatterns += [ # one homepage pattern, so if you use a different one, comment this # one out. - url("^styles/$", direct_to_template, {"template": "styles.html"}, name="styles"), - url("^$", direct_to_template, {"template": "index.html"}, name="home"), + # url("^$", direct_to_template, {"template": "index.html"}, name="home"), # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE # ---------------------------------------------