]> git.parisson.com Git - mezzo.git/commitdiff
File Block : add to Person & Project | repair person list in customPage
authorEmilie <zawadzki@ircam.fr>
Wed, 28 Sep 2016 13:10:02 +0000 (15:10 +0200)
committerEmilie <zawadzki@ircam.fr>
Wed, 28 Sep 2016 13:10:02 +0000 (15:10 +0200)
app/organization/core/models.py
app/organization/network/admin.py
app/organization/network/migrations/0024_personfile.py [new file with mode: 0644]
app/organization/network/models.py
app/organization/network/translation.py
app/organization/projects/admin.py
app/organization/projects/migrations/0016_projectfile.py [new file with mode: 0644]
app/organization/projects/models.py
app/organization/projects/translation.py
app/templates/network/inc/person/list_circle_style.html
app/templates/pages/custompage.html

index dc6d6f64280b2d2b46f3f7c0cb5c51c7de9b50e1..2d93ea20215e3e8fc23862d2038443ef05e882fa 100644 (file)
@@ -100,6 +100,22 @@ class Image(Titled, Orderable):
         return value
 
 
+class File(Titled, Orderable):
+
+    file = FileField(_("document"), max_length=1024, upload_to="Documents/%Y/%m/%d/")
+
+    class Meta:
+        abstract = True
+
+    def __str__(self):
+        value = self.description
+        if not value:
+            value = self.file.name
+        if not value:
+            value = ""
+        return value
+
+
 class DynamicContent(models.Model):
 
     # used for autocomplete but hidden in admin
index b2527e859668bca66bb81c7760c9ae59e326a104..87508dc517de8a80b5d7fe28873f49df6f1ce26f 100644 (file)
@@ -98,6 +98,11 @@ class PersonImageInline(TabularDynamicInlineAdmin):
     model = PersonImage
 
 
+class PersonFileInline(TabularDynamicInlineAdmin):
+
+    model = PersonFile
+
+
 class PersonBlockInline(StackedDynamicInlineAdmin):
 
     model = PersonBlock
@@ -106,7 +111,13 @@ class PersonBlockInline(StackedDynamicInlineAdmin):
 class PersonAdmin(BaseTranslationOrderedModelAdmin):
 
     model = Person
-    inlines = [PersonActivityInline, PersonAudioInline, PersonImageInline, PersonVideoInline, PersonBlockInline, PersonLinkInline ]
+    inlines = [PersonActivityInline,
+               PersonAudioInline,
+               PersonImageInline,
+               PersonVideoInline,
+               PersonBlockInline,
+               PersonLinkInline,
+               PersonFileInline ]
     first_fields = ['last_name', 'first_name', 'title', 'gender', 'user']
     search_fields = ['last_name', 'first_name']
 
diff --git a/app/organization/network/migrations/0024_personfile.py b/app/organization/network/migrations/0024_personfile.py
new file mode 100644 (file)
index 0000000..c6d3fa1
--- /dev/null
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-09-28 12:32
+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', '0023_auto_20160921_2043'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='PersonFile',
+            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', mezzanine.core.fields.FileField(max_length=1024, verbose_name='document')),
+                ('person', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='files', to='organization-network.Person', verbose_name='person')),
+            ],
+            options={
+                'ordering': ('_order',),
+            },
+        ),
+    ]
index 37b71265a435594b311edba0f238539794834ab4..9bf3ab18025f6317cef503c2a000ca51215e2673 100644 (file)
@@ -234,6 +234,11 @@ class PersonImage(Image):
     person = models.ForeignKey(Person, verbose_name=_('person'), related_name='images', blank=True, null=True, on_delete=models.SET_NULL)
 
 
+class PersonFile(File):
+
+    person = models.ForeignKey(Person, verbose_name=_('person'), related_name='files', blank=True, null=True, on_delete=models.SET_NULL)
+
+
 class PersonBlock(Block):
 
     person = models.ForeignKey(Person, verbose_name=_('person'), related_name='blocks', blank=True, null=True, on_delete=models.SET_NULL)
index 9319ba8d36090b497f3970dc1b527564e58718d6..fec21ee2a6f47cf1f26b849be3d90d6386e7142d 100644 (file)
@@ -69,6 +69,12 @@ class PersonImageTranslationOptions(TranslationOptions):
     pass
 
 
+@register(PersonFile)
+class PersonFileTranslationOptions(TranslationOptions):
+
+    pass
+
+
 @register(PersonBlock)
 class PersonBlockTranslationOptions(TranslationOptions):
 
index bd9eb4a3bdcde2426f3d6085be263fcc10a2452d..e2932d268a08aabb587a7b1fb97177e10a6840e2 100644 (file)
@@ -36,6 +36,11 @@ class ProjectVideoInline(StackedDynamicInlineAdmin):
     model = ProjectVideo
 
 
+class ProjectFileInline(TabularDynamicInlineAdmin):
+
+    model = ProjectFile
+
+
 class ProjectAdmin(admin.ModelAdmin):
 
     model = Project
@@ -44,7 +49,12 @@ class ProjectAdmin(admin.ModelAdmin):
 class ProjectAdminDisplayable(DisplayableAdmin):
 
     fieldsets = deepcopy(ProjectAdmin.fieldsets)
-    inlines = [ ProjectBlockInline, ProjectImageInline, ProjectAudioInline, ProjectVideoInline, ProjectLinkInline]
+    inlines = [ ProjectBlockInline,
+                ProjectImageInline,
+                ProjectAudioInline,
+                ProjectVideoInline,
+                ProjectLinkInline,
+                ProjectFileInline]
     filter_horizontal = ['teams', 'organizations']
     list_filter = ['type', 'program', 'program_type', ]
 
diff --git a/app/organization/projects/migrations/0016_projectfile.py b/app/organization/projects/migrations/0016_projectfile.py
new file mode 100644 (file)
index 0000000..6300e36
--- /dev/null
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-09-28 13:02
+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', '0015_project_lead_organization'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='ProjectFile',
+            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', mezzanine.core.fields.FileField(max_length=1024, verbose_name='document')),
+                ('project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='files', to='organization-projects.Project', verbose_name='project')),
+            ],
+            options={
+                'ordering': ('_order',),
+            },
+        ),
+    ]
index abef3c3d4850dcb896467550467881207af9917e..70d3f248b01ce22e49f8e04064ef7c798b870b64 100644 (file)
@@ -99,6 +99,11 @@ class ProjectImage(Image):
     project = models.ForeignKey(Project, verbose_name=_('project'), related_name='images', blank=True, null=True, on_delete=models.SET_NULL)
 
 
+class ProjectFile(File):
+
+    project = models.ForeignKey(Project, verbose_name=_('project'), related_name='files', blank=True, null=True, on_delete=models.SET_NULL)
+
+
 class ProjectBlock(Block):
 
     project = models.ForeignKey(Project, verbose_name=_('project'), related_name='blocks', blank=True, null=True, on_delete=models.SET_NULL)
index 302cbeeaf8bfb0ece226075e30a4b6bf453e6c99..fea7a757e074651296f8901970691aee846e4b5b 100644 (file)
@@ -27,6 +27,12 @@ class ProjectImageTranslationOptions(TranslationOptions):
     pass
 
 
+@register(ProjectFile)
+class ProjectFileTranslationOptions(TranslationOptions):
+
+    pass
+
+
 @register(ProjectBlock)
 class ProjectBlockTranslationOptions(TranslationOptions):
 
index de0911d47ba5eae0ed0f7334e94692d243ca087b..08e4a94ece61a82d5972d1135a956d0066e46fb8 100644 (file)
@@ -59,8 +59,9 @@
                                         {% elif person.bio %}
                                             <div class="person-list-box__desc">{{ person.bio|richtext_filters|safe }}</div>
                                         {% endif %}
-
-                                        <a href="{{ person.get_absolute_url }}" class="button button--small">{% trans "resume" %}</a>
+                                        {% if person.files.first %}
+                                            <a href="{{ person.files.first.file.url }}" class="button button--small">{% trans "resume" %}</a>
+                                        {% endif %}
                                         {% for link in person.links.all %}
                                             {% if link %}
                                                 <a href="{{ link }}" title="Site Web" class="button button--small"><i class="fa fa-{{ link.link_type.name }}"></i> {{ link.link_type.name }}</a>
index 2d9ac1a2e0c56a2d4ae0e737f9ccd8f38bb14776..56a5b6d50ecbda31c4ab8ee8b4b9ea7a5c102985 100644 (file)
 {% endblock %}
 
 {% block page_person_list %}
-  {% for inline in page.custompage.page_custom_person_list_block_inlines.all  %}
-    {% with "network/inc/person/list_"|add:inline.person_list_block.style|add:"_style.html" as template %}
-      {% include template %}
-    {% endwith %}
-  {% endfor %}
+    {% for page_custom_person_list_block_inline in page.custompage.page_custom_person_list_block_inlines.all  %}
+        {% with page_custom_person_list_block_inline.person_list_block as person_list_block %}
+            {% with "network/inc/person/list_"|add:person_list_block.style|add:"_style.html" as template %}
+                {% include template %}
+            {% endwith %}
+        {% endwith %}
+    {% endfor %}
 {% endblock %}
 
 {% block page_sub_content %}