]> git.parisson.com Git - mezzo.git/commitdiff
Add Organization.role, update ProducerCreateView, rename SimpleImage to UserImage
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 13 Mar 2017 11:27:21 +0000 (12:27 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 13 Mar 2017 11:27:21 +0000 (12:27 +0100)
app/organization/agenda/migrations/0026_auto_20170313_1224.py [new file with mode: 0644]
app/organization/core/models.py
app/organization/network/migrations/0090_auto_20170313_1224.py [new file with mode: 0644]
app/organization/network/models.py
app/organization/projects/admin.py
app/organization/projects/forms.py
app/organization/projects/migrations/0050_auto_20170313_1224.py [new file with mode: 0644]
app/organization/projects/models.py
app/organization/projects/translation.py
app/organization/projects/views.py

diff --git a/app/organization/agenda/migrations/0026_auto_20170313_1224.py b/app/organization/agenda/migrations/0026_auto_20170313_1224.py
new file mode 100644 (file)
index 0000000..fbf75f8
--- /dev/null
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.11 on 2017-03-13 11:24
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('organization-agenda', '0025_auto_20170222_1011'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='eventtraining',
+            name='language',
+            field=models.CharField(blank=True, choices=[('en', 'English'), ('fr', 'French')], max_length=64, null=True, verbose_name='language'),
+        ),
+    ]
index 3811a4d14e6815b13955176de48bc0e0456aa4cf..e53ea76c3da49d8773bbcc23fcc2531081f8f0f3 100644 (file)
@@ -138,7 +138,7 @@ class Image(Titled, Orderable):
         return value
 
 
-class SimpleImage(Titled, Orderable):
+class UserImage(Titled, Orderable):
 
     file = models.FileField(_("Image"), max_length=1024, upload_to="images")
     credits = models.CharField(_('credits'), max_length=256, blank=True, null=True)
diff --git a/app/organization/network/migrations/0090_auto_20170313_1224.py b/app/organization/network/migrations/0090_auto_20170313_1224.py
new file mode 100644 (file)
index 0000000..973afe5
--- /dev/null
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.11 on 2017-03-13 11:24
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import mezzanine.core.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('organization-network', '0089_auto_20170303_1637'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='OrganizationContact',
+            fields=[
+                ('person_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='organization-network.Person')),
+            ],
+            options={
+                'verbose_name': 'Organization contact',
+                'verbose_name_plural': 'Organization contacts',
+            },
+            bases=('organization-network.person',),
+        ),
+        migrations.CreateModel(
+            name='OrganizationUserImage',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('_order', mezzanine.core.fields.OrderField(null=True, verbose_name='Order')),
+                ('title', models.CharField(max_length=1024, verbose_name='title')),
+                ('description', models.TextField(blank=True, verbose_name='description')),
+                ('file', models.FileField(max_length=1024, upload_to='images', verbose_name='Image')),
+                ('credits', models.CharField(blank=True, max_length=256, null=True, verbose_name='credits')),
+            ],
+            options={
+                'ordering': ('_order',),
+            },
+        ),
+        migrations.AddField(
+            model_name='organization',
+            name='role',
+            field=models.CharField(blank=True, choices=[('coordinator', 'coordinator'), ('producer', 'producer')], max_length=128, null=True, verbose_name='role'),
+        ),
+        migrations.AddField(
+            model_name='organizationuserimage',
+            name='organization',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='user_images', to='organization-network.Organization', verbose_name='organization'),
+        ),
+        migrations.AddField(
+            model_name='organizationcontact',
+            name='organization',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='contacts', to='organization-network.Organization', verbose_name='organization'),
+        ),
+    ]
index 27872ae9792d90843a891e85b486fe04b6a88681..7aee2c81955e0215f51daea29e6838024e5fdf71 100644 (file)
@@ -112,6 +112,11 @@ BOX_SIZE_CHOICES = [
     (6, 6),
 ]
 
+ORGANIZATION_ROLE_CHOICES = [
+    ('coordinator', _('coordinator')),
+    ('producer', _('producer')),
+]
+
 
 class Organization(Named, Address, URL, AdminThumbRelatedMixin, Orderable):
     """(Organization description)"""
@@ -129,6 +134,7 @@ class Organization(Named, Address, URL, AdminThumbRelatedMixin, Orderable):
     bio = models.TextField(_('bio'), blank=True)
     site = models.ForeignKey("sites.Site", blank=True, null=True, on_delete=models.SET_NULL)
     admin_thumb_type = 'logo'
+    role = models.CharField(_('role'), max_length=128, blank=True, null=True, choices=ORGANIZATION_ROLE_CHOICES)
 
     class Meta:
         verbose_name = _('organization')
@@ -169,6 +175,84 @@ class Organization(Named, Address, URL, AdminThumbRelatedMixin, Orderable):
         super(Organization, self).save()
 
 
+class Team(Named, URL):
+    """(Team description)"""
+
+    organization = models.ForeignKey('Organization', verbose_name=_('organization'), related_name="teams", 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)
+    code = models.CharField(_('code'), max_length=64, blank=True, null=True)
+    is_legacy = models.BooleanField(_('is legacy'), default=False)
+    parent = models.ForeignKey('Team', verbose_name=_('parent team'), related_name="children", blank=True, null=True, on_delete=models.SET_NULL)
+
+    class Meta:
+        verbose_name = _('team')
+        ordering = ['name',]
+
+    def __str__(self):
+        if self.organization:
+            return ' - '.join((self.organization.name, self.name))
+        elif self.department:
+            if self.department.organization:
+                return ' - '.join((self.department.organization.name, self.department.name, self.name))
+            else:
+                return ' - '.join((self.department.name, self.name))
+        return self.name
+
+    @property
+    def short(self):
+        if self.organization:
+            return ' - '.join((self.organization.name, self.name))
+        elif self.department:
+            if self.department.organization:
+                return ' - '.join((self.department.organization.name, self.name))
+            else:
+                return ' - '.join((self.department.name, self.name))
+        return self.name
+
+
+class Person(Displayable, AdminThumbMixin, Address):
+    """(Person description)"""
+
+    user = models.OneToOneField(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)
+    email = models.EmailField(_('email'), blank=True, null=True)
+    telephone = models.CharField(_('telephone'), max_length=64, blank=True, null=True)
+    register_id = models.CharField(_('register ID'), blank=True, null=True, max_length=128)
+    birthday = models.DateField(_('birthday'), blank=True, null=True)
+    bio = RichTextField(_('biography'), blank=True)
+    external_id = models.CharField(_('external ID'), blank=True, null=True, max_length=128)
+
+    class Meta:
+        verbose_name = _('person')
+        ordering = ['last_name',]
+
+    def __str__(self):
+        return self.title
+
+    def get_absolute_url(self):
+        return reverse("organization-network-person-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 save(self, *args, **kwargs):
+        super(Person, self).save(args, kwargs)
+        for activity in self.activities.all():
+            update_activity(activity)
+
+
 class OrganizationLinkedBlockInline(Titled, Orderable):
     organization_linked = models.ForeignKey('OrganizationLinked', verbose_name=_('organization list'), related_name='organization_linked_block_inline_list', blank=True, null=True)
     organization_main = models.ForeignKey('Organization', verbose_name=_('organization'), related_name='organization_linked_block', blank=True, null=True, on_delete=models.SET_NULL)
@@ -228,6 +312,20 @@ class OrganizationType(Named):
         ordering = ['name',]
 
 
+class OrganizationContact(Person):
+
+    organization = models.ForeignKey(Organization, verbose_name=_('organization'), related_name='contacts', blank=True, null=True, on_delete=models.SET_NULL)
+
+    class Meta:
+        verbose_name = 'Organization contact'
+        verbose_name_plural = 'Organization contacts'
+
+
+class OrganizationUserImage(UserImage):
+
+    organization = models.ForeignKey(Organization, verbose_name=_('organization'), related_name='user_images', blank=True, null=True, on_delete=models.SET_NULL)
+
+
 class Department(Named):
     """(Department description)"""
 
@@ -253,41 +351,6 @@ class DepartmentPage(Page, SubTitled, RichText):
         verbose_name = _('department page')
 
 
-class Team(Named, URL):
-    """(Team description)"""
-
-    organization = models.ForeignKey('Organization', verbose_name=_('organization'), related_name="teams", 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)
-    code = models.CharField(_('code'), max_length=64, blank=True, null=True)
-    is_legacy = models.BooleanField(_('is legacy'), default=False)
-    parent = models.ForeignKey('Team', verbose_name=_('parent team'), related_name="children", blank=True, null=True, on_delete=models.SET_NULL)
-
-    class Meta:
-        verbose_name = _('team')
-        ordering = ['name',]
-
-    def __str__(self):
-        if self.organization:
-            return ' - '.join((self.organization.name, self.name))
-        elif self.department:
-            if self.department.organization:
-                return ' - '.join((self.department.organization.name, self.department.name, self.name))
-            else:
-                return ' - '.join((self.department.name, self.name))
-        return self.name
-
-    @property
-    def short(self):
-        if self.organization:
-            return ' - '.join((self.organization.name, self.name))
-        elif self.department:
-            if self.department.organization:
-                return ' - '.join((self.department.organization.name, self.name))
-            else:
-                return ' - '.join((self.department.name, self.name))
-        return self.name
-
-
 class TeamPage(Page, SubTitled, RichText):
     """(Team description)"""
 
@@ -302,49 +365,6 @@ class TeamLink(Link):
     team = models.ForeignKey(Team, verbose_name=_('team'), related_name='links', blank=True, null=True, on_delete=models.SET_NULL)
 
 
-class Person(Displayable, AdminThumbMixin, Address):
-    """(Person description)"""
-
-    user = models.OneToOneField(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)
-    email = models.EmailField(_('email'), blank=True, null=True)
-    telephone = models.CharField(_('telephone'), max_length=64, blank=True, null=True)
-    register_id = models.CharField(_('register ID'), blank=True, null=True, max_length=128)
-    birthday = models.DateField(_('birthday'), blank=True, null=True)
-    bio = RichTextField(_('biography'), blank=True)
-    external_id = models.CharField(_('external ID'), blank=True, null=True, max_length=128)
-
-    class Meta:
-        verbose_name = _('person')
-        ordering = ['last_name',]
-
-    def __str__(self):
-        return self.title
-
-    def get_absolute_url(self):
-        return reverse("organization-network-person-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 save(self, *args, **kwargs):
-        super(Person, self).save(args, kwargs)
-        for activity in self.activities.all():
-            update_activity(activity)
-
-
 class PersonPlaylist(PlaylistRelated):
 
     person = models.ForeignKey(Person, verbose_name=_('person'), related_name='playlists', blank=True, null=True, on_delete=models.SET_NULL)
index 2d7ed3edc23fb3b1d3e7c515a0cbb28dea8b88f3..5316a2b1d8ff6aec08b25a584e98d4b8c92baa64 100644 (file)
@@ -81,9 +81,9 @@ class ProjectBlogPageInline(StackedDynamicInlineAdmin):
     model = ProjectBlogPage
 
 
-class ProjectSimpleImageInline(StackedDynamicInlineAdmin):
+class ProjectUserImageInline(StackedDynamicInlineAdmin):
 
-    model = ProjectSimpleImage
+    model = ProjectUserImage
 
 
 class ProjectContactInline(StackedDynamicInlineAdmin):
@@ -122,7 +122,7 @@ class ProjectAdminDisplayable(DisplayableAdmin):
     fieldsets = deepcopy(ProjectAdmin.fieldsets)
     inlines = [ ProjectBlockInline,
                 ProjectContactInline,
-                ProjectSimpleImageInline,
+                ProjectUserImageInline,
                 ProjectImageInline,
                 ProjectICTDataInline,
                 ProjectWorkPackageInline,
index 14c137a3b6ea5225375c637b888be9ba2710487c..ed8149922ab79892c26b7e6b82abee582661a3f4 100644 (file)
@@ -68,10 +68,10 @@ class ProjectICTDataInline(InlineFormSet):
     can_delete = False
     fields = '__all__'
 
-class ProjectSimpleImageInline(InlineFormSet):
+class ProjectUserImageInline(InlineFormSet):
 
     max_num = 4
-    model = ProjectSimpleImage
+    model = ProjectUserImage
     prefix = 'Images'
     can_delete = False
     fields = ['file', 'credits']
diff --git a/app/organization/projects/migrations/0050_auto_20170313_1224.py b/app/organization/projects/migrations/0050_auto_20170313_1224.py
new file mode 100644 (file)
index 0000000..42f514d
--- /dev/null
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.11 on 2017-03-13 11:24
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+import mezzanine.core.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('organization-projects', '0049_auto_20170310_1658'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='ProjectUserImage',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('_order', mezzanine.core.fields.OrderField(null=True, verbose_name='Order')),
+                ('title', models.CharField(max_length=1024, verbose_name='title')),
+                ('description', models.TextField(blank=True, verbose_name='description')),
+                ('file', models.FileField(max_length=1024, upload_to='images', verbose_name='Image')),
+                ('credits', models.CharField(blank=True, max_length=256, null=True, verbose_name='credits')),
+                ('project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='user_images', to='organization-projects.Project', verbose_name='project')),
+            ],
+            options={
+                'ordering': ('_order',),
+            },
+        ),
+        migrations.RemoveField(
+            model_name='projectsimpleimage',
+            name='project',
+        ),
+        migrations.DeleteModel(
+            name='ProjectSimpleImage',
+        ),
+    ]
index 75a2c5205f26ffc15c31b13c93fdf93b2f5b1c31..80c8a7b47b0425e1ec4a0f72c0770edb9e6c7cbb 100644 (file)
@@ -154,9 +154,9 @@ class ProjectImage(Image):
     project = models.ForeignKey(Project, verbose_name=_('project'), related_name='images', blank=True, null=True, on_delete=models.SET_NULL)
 
 
-class ProjectSimpleImage(SimpleImage):
+class ProjectUserImage(UserImage):
 
-    project = models.ForeignKey(Project, verbose_name=_('project'), related_name='simple_images', blank=True, null=True, on_delete=models.SET_NULL)
+    project = models.ForeignKey(Project, verbose_name=_('project'), related_name='user_images', blank=True, null=True, on_delete=models.SET_NULL)
 
 
 class ProjectFile(File):
index 886d0a02437bc355cbd381623901ed56e20472ad..d263f3f77033358dbcdf5fd43cccf26b65da08ab 100644 (file)
@@ -42,8 +42,8 @@ class ProjectImageTranslationOptions(TranslationOptions):
     pass
 
 
-@register(ProjectSimpleImage)
-class ProjectSimpleImageTranslationOptions(TranslationOptions):
+@register(ProjectUserImage)
+class ProjectUserImageTranslationOptions(TranslationOptions):
 
     pass
 
index 6a1e17a7859a73bcba85a8bef56605f63634b52e..ca2c49e1d043f6817f002faec7921edad78562b6 100644 (file)
@@ -132,7 +132,7 @@ class ProjectICTCreateView(CreateWithInlinesView):
     model = Project
     form_class = ProjectForm
     template_name='projects/project_ict_create.html'
-    inlines = [ProjectICTDataInline, ProjectSimpleImageInline, ProjectContactInline,]
+    inlines = [ProjectICTDataInline, ProjectUserImageInline, ProjectContactInline,]
 
     def get_context_data(self, **kwargs):
         context = super(ProjectICTCreateView, self).get_context_data(**kwargs)
@@ -168,13 +168,23 @@ class ProducerListView(ListView):
     model = Organization
     template_name='projects/project_producer_list.html'
 
+    def get_queryset(self):
+        qs = Organization.objects.filter(role='producer')
+        return qs
+
 
 class ProducerCreateView(CreateWithInlinesView):
 
     model = Organization
     form_class = ProducerForm
     template_name='projects/project_producer_create.html'
-    # inlines = [OrganizationICTDataInline, OrganizationSimpleImageInline, OrganizationContactInline,]
+    # inlines = [OrganizationICTDataInline, OrganizationUserImageInline, OrganizationContactInline,]
+
+    def forms_valid(self, form, inlines):
+        self.object = form.save()
+        self.object.role = 'producer'
+        self.object.save()
+        return super(ProducerCreateView, self).form_valid(form)
 
 
 class ProjectResidencyDetailView(SlugMixin, DetailView):