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
model = PersonImage
+class PersonFileInline(TabularDynamicInlineAdmin):
+
+ model = PersonFile
+
+
class PersonBlockInline(StackedDynamicInlineAdmin):
model = PersonBlock
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']
--- /dev/null
+# -*- 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',),
+ },
+ ),
+ ]
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)
pass
+@register(PersonFile)
+class PersonFileTranslationOptions(TranslationOptions):
+
+ pass
+
+
@register(PersonBlock)
class PersonBlockTranslationOptions(TranslationOptions):
model = ProjectVideo
+class ProjectFileInline(TabularDynamicInlineAdmin):
+
+ model = ProjectFile
+
+
class ProjectAdmin(admin.ModelAdmin):
model = Project
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', ]
--- /dev/null
+# -*- 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',),
+ },
+ ),
+ ]
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)
pass
+@register(ProjectFile)
+class ProjectFileTranslationOptions(TranslationOptions):
+
+ pass
+
+
@register(ProjectBlock)
class ProjectBlockTranslationOptions(TranslationOptions):
{% 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>
{% 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 %}