(_('Magazine'), ('organization-magazine.Article',
'organization-magazine.Brief',)),
(_('Network'), ('organization-network.Organization',
+ 'organization-network.OrganizationLinked',
'organization-network.Department',
'organization-network.Team',
'organization-network.Person',
from django.conf import settings # import the settings file
from datetime import datetime, date
from organization.pages.models import Page
-from organization.network.models import Organization
+from organization.network.models import Organization, OrganizationLinkedInline
def settings(request):
date_now = datetime.now()
if newsletter_page:
newsletter_subscribing_url = newsletter_page.first().get_absolute_url()
- # HOST ORGANIZATION
+ # HOST ORGANIZATIONS
host_org = Organization.objects.get(is_host=True)
- linked_org_content = host_org.organizations_content.filter(organizations_content__id=host_org.id).order_by('order')
- linked_org_footer = host_org.organizations_footer.filter(organizations_footer__id=host_org.id).order_by('order')
+ organization_lists = []
+
+ for orga_linked_block in host_org.organization_linked_block.all():
+ organizations = []
+ for orga_list in OrganizationLinkedInline.objects.filter(organization_list_id=orga_linked_block.organization_linked_id):
+ organizations.append(orga_list.organization)
+ organization_lists.append(organizations)
+
+ linked_org_content = organization_lists[0] if len(organization_lists) > 0 else None
+ linked_org_footer = organization_lists[1] if len(organization_lists) > 1 else None
+ linked_org_footer_2 = organization_lists[2] if len(organization_lists) > 2 else None
+
research_slug = "recherche"
return {'current_season': current_season,
'host_organization': host_org,
'linked_organization_content' : linked_org_content,
'linked_organization_footer' : linked_org_footer,
+ 'linked_organization_footer_2' : linked_org_footer_2,
'research_slug' : research_slug
}
from organization.shop.models import PageProductList
+class OrganizationAdminInline(StackedDynamicInlineAdmin):
+
+ model = OrganizationLinkedInline
+ form = OrganizationLinkedForm
+
+
+class OrganizationLinkedAdmin(BaseTranslationOrderedModelAdmin):
+
+ inlines = (OrganizationAdminInline,)
+ first_fields = ['name',]
+
+ class Media:
+ js = (
+ static("mezzanine/js/admin/dynamic_inline.js"),
+ )
+
+
+class OrganizationLinkedBlockInlineAdmin(StackedDynamicInlineAdmin):
+
+ model = OrganizationLinkedBlockInline
+ form = OrganizationLinkedListForm
+
+
class OrganizationPlaylistInline(TabularDynamicInlineAdmin):
model = OrganizationPlaylist
model = OrganizationBlock
-class OrganizationAdmin(BaseTranslationModelAdmin):
+class OrganizationAdmin(BaseTranslationOrderedModelAdmin):
model = Organization
inlines = [ OrganizationPlaylistInline,
OrganizationImageInline,
OrganizationBlockInline,
- OrganizationLinkInline ]
- filter_horizontal = ['organizations_content', 'organizations_footer']
+ OrganizationLinkInline,
+ OrganizationLinkedBlockInlineAdmin
+ ]
list_display = ['name', 'type', 'admin_thumb']
list_filter = ['is_on_map',]
search_fields = ['name',]
+ first_fields = ['name',]
+
class PageProductListInline(TabularDynamicInlineAdmin):
model = TrainingTopic
+admin.site.register(OrganizationLinked, OrganizationLinkedAdmin)
admin.site.register(Organization, OrganizationAdmin)
admin.site.register(OrganizationType)
admin.site.register(Department, DepartmentAdmin)
from django.forms.widgets import HiddenInput
from django.forms import ModelForm
from mezzanine.core.models import Orderable
-from organization.network.models import Person, PersonListBlock, PersonListBlockInline, PageCustomPersonListBlockInline
+from organization.network.models import (Person,
+ PersonListBlock,
+ PersonListBlockInline,
+ PageCustomPersonListBlockInline,
+ OrganizationLinked,
+ OrganizationLinkedInline,
+ OrganizationLinkedBlockInline,
+ Organization)
from organization.pages.models import Page, CustomPage
class Meta:
model = PersonListBlockInline
fields = ('__all__')
+
+
+class OrganizationLinkedListForm(forms.ModelForm):
+
+ organization_linked = forms.ModelChoiceField(
+ queryset=OrganizationLinked.objects.all(),
+ widget=autocomplete.ModelSelect2(url='organization-linked-list-autocomplete')
+ )
+
+ class Meta:
+ model = OrganizationLinkedBlockInline
+ fields = ('organization_linked',)
+
+
+class OrganizationLinkedForm(forms.ModelForm):
+
+ organization = forms.ModelChoiceField(
+ queryset=Organization.objects.all(),
+ widget=autocomplete.ModelSelect2(url='organization-linked-autocomplete')
+ )
+
+ class Meta:
+ model = OrganizationLinkedInline
+ fields = ('organization',)
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.11 on 2016-12-08 11:44
+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', '0064_auto_20161205_1536'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='OrganizationLinked',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('title', models.CharField(max_length=1024, verbose_name='title')),
+ ('description', models.TextField(blank=True, verbose_name='description')),
+ ],
+ options={
+ 'verbose_name': 'Organization Linked',
+ },
+ ),
+ migrations.CreateModel(
+ name='OrganizationLinkedBlockInline',
+ 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')),
+ ('organization_linked', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='organization_linked_block_inline_list', to='organization-network.OrganizationLinked', verbose_name='organization list')),
+ ],
+ options={
+ 'ordering': ('_order',),
+ },
+ ),
+ migrations.CreateModel(
+ name='OrganizationLinkedInline',
+ 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')),
+ ],
+ options={
+ 'ordering': ('_order',),
+ },
+ ),
+ migrations.RemoveField(
+ model_name='organization',
+ name='order',
+ ),
+ migrations.RemoveField(
+ model_name='organization',
+ name='organizations_content',
+ ),
+ migrations.RemoveField(
+ model_name='organization',
+ name='organizations_footer',
+ ),
+ migrations.AddField(
+ model_name='organization',
+ name='_order',
+ field=mezzanine.core.fields.OrderField(null=True, verbose_name='Order'),
+ ),
+ migrations.AddField(
+ model_name='organizationlinkedinline',
+ name='organization',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='organization_linked_inline_from', to='organization-network.Organization', verbose_name='organization'),
+ ),
+ migrations.AddField(
+ model_name='organizationlinkedinline',
+ name='organization_list',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='organization_linked_inline_linked', to='organization-network.OrganizationLinked', verbose_name='organization linked'),
+ ),
+ migrations.AddField(
+ model_name='organizationlinkedblockinline',
+ name='organization_main',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='organization_linked_block', to='organization-network.Organization', verbose_name='organization'),
+ ),
+ ]
ALIGNMENT_CHOICES = (('left', _('left')), ('left', _('left')), ('right', _('right')))
-class Organization(Named, Address, URL, AdminThumbRelatedMixin):
+class Organization(Named, Address, URL, AdminThumbRelatedMixin, Orderable):
"""(Organization description)"""
mappable_location = models.CharField(max_length=128, blank=True, null=True, help_text="This address will be used to calculate latitude and longitude. Leave blank and set Latitude and Longitude to specify the location yourself, or leave all three blank to auto-fill from the Location field.")
telephone = models.CharField(_('telephone'), max_length=64, blank=True, null=True)
opening_times = models.TextField(_('opening times'), blank=True)
subway_access = models.TextField(_('subway access'), blank=True)
- organizations_content = models.ManyToManyField('self', verbose_name=_('Linked organizations (in content)'), related_name='organizations_content', blank=True, help_text="Usefull for host organization")
- organizations_footer = models.ManyToManyField('self', verbose_name=_('Linked organizations (in footer)'), related_name='organizations_footer', blank=True, help_text="Usefull for host organization")
- order = models.IntegerField(_('order number'), default=10)
-
admin_thumb_type = 'logo'
class Meta:
super(Organization, self).save()
+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)
+
+
+class OrganizationLinked(Titled):
+
+ class Meta:
+ verbose_name = _('Organization Linked')
+
+ def __str__(self):
+ return self.title
+
+
+class OrganizationLinkedInline(Titled, Orderable):
+
+ organization_list = models.ForeignKey('OrganizationLinked', verbose_name=_('organization linked'), related_name='organization_linked_inline_linked', blank=True, null=True, on_delete=models.SET_NULL)
+ organization = models.ForeignKey('Organization', verbose_name=_('organization'), related_name='organization_linked_inline_from', blank=True, null=True, on_delete=models.SET_NULL)
+
+
class OrganizationPlaylist(PlaylistRelated):
organization = models.ForeignKey(Organization, verbose_name=_('organization'), related_name='playlists', blank=True, null=True, on_delete=models.SET_NULL)
class TrainingSpecialityTranslationOptions(TranslationOptions):
fields = ['name', 'description']
+
+
+@register(OrganizationLinked)
+class OrganizationLinkedTranslationOptions(TranslationOptions):
+
+ fields = []
+
+
+@register(OrganizationLinkedInline)
+class OrganizationLinkedInlineTranslationOptions(TranslationOptions):
+
+ fields = []
+
+
+@register(OrganizationLinkedBlockInline)
+class OrganizationLinkedBlockInlineTranslationOptions(TranslationOptions):
+
+ fields = []
url("^person-list-block-autocomplete/$", permission_required('person.can_edit')(PersonListBlockAutocompleteView.as_view()), name='person-list-block-autocomplete'),
url("^person-autocomplete/$", permission_required('person.can_edit')(PersonListView.as_view()), name='person-autocomplete'),
url("^network/$", OrganizationListView.as_view(), name='network'),
+ url("^organization-linked-list-autocomplete/$", permission_required('organization.can_edit')(OrganizationLinkedListView.as_view()), name='organization-linked-list-autocomplete'),
+ url("^organization-linked-autocomplete/$", permission_required('organization.can_edit')(OrganizationLinkedView.as_view()), name='organization-linked-autocomplete'),
+
]
context = super(OrganizationListView, self).get_context_data(**kwargs)
context['organization_types'] = self.get_queryset().values_list('type__name', 'type__css_class').order_by('type__name').distinct('type__name')
return context
+
+
+class OrganizationLinkedListView(autocomplete.Select2QuerySetView):
+
+ def get_queryset(self):
+ qs = OrganizationLinked.objects.all()
+ orga_linked_title = self.forwarded.get('title', None)
+ if orga_linked_title:
+ qs = qs.filter(title=orga_linked_title)
+ if self.q:
+ qs = qs.filter(title__istartswith=self.q)
+ return qs
+
+
+class OrganizationLinkedView(autocomplete.Select2QuerySetView):
+
+ def get_queryset(self):
+ qs = Organization.objects.all()
+ orga_name= self.forwarded.get('name', None)
+ if orga_name:
+ qs = qs.filter(name=orga_name)
+ if self.q:
+ qs = qs.filter(name__istartswith=self.q)
+ return qs
&__item {
display: inline-block;
- width: 40px;
- height: 40px;
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
@include margin(0 1 0 0);
a {
- width : 40px;
- height : 40px;
+ display: inline-block;
}
}
+++ /dev/null
-{% load organization_tags %}
-<div class="row">
- <div class="pull-right">
- <ul class="linked-organizations">
- {% for loc in linked_organization_content %}
- {% with loc.images|get_type:"logo_black"|first as img %}
- <li class="linked-organizations__item">
- <a href="{{ loc.url }}" title="{{ loc.title }}" target="_blank">
- <img src="{{ MEDIA_URL }}{{ img }}" title="{{ img.title }}" />
- </a>
- </li>
- {% endwith %}
- {% endfor %}
- </ul>
- </div>
-</div>
+++ /dev/null
-{% load organization_tags %}
-{% for lof in linked_organization_footer %}
- <a href="{{ lof.url }}" target="_blank" title="{{ lof.name }}">
- {% with lof.images|get_type:"logo_white"|first as img %}
- <img class="footer__partner" src="{{ MEDIA_URL }}{{ img }}" title="{{ img.title }}" width="120" height="66" />
- {% endwith %}
- </a>
-{% endfor %}
<strong>{{ host_organization.description }}</strong><br/ >{% trans 'under the tutelage of' %} :<br />
<br />
{% if linked_organization_footer %}
- {% include 'core/inc/linked_organization_footer.html' %}
+ {% include 'pages/page/includes/linked_organization_footer.html' %}
{% endif %}
</div>
<div class="col-xs-4 col-sm-2 col-sm-push-1 tal">
{% trans 'go to' %} :
- <ul class="unstyled-list">
- <li>
- <a class="footer__link" href="https://www.centrepompidou.fr/" target="_blank" title="Centre Pompidou">Centre Pompidou</a>
- </li>
- <li>
- <a class="footer__link" href="http://www.bpi.fr/home.html" target="_blank" title="Bibliothèque Publique d’Information">Bibliothèque Publique d’Information</a>
- </li>
- </ul>
+ {% if linked_organization_footer_2 %}
+ {% include 'pages/page/includes/linked_organization_footer_2.html' %}
+ {% endif %}
</div>
</div>
{% with page.get_ascendants|last as top_level_parent %}
{% if linked_organization_content and research_slug == top_level_parent.slug %}
- {% include 'core/inc/linked_organization_content.html' %}
+ {% include 'pages/page/includes/linked_organization_content.html' %}
{% endif %}
{% endwith %}
</div>
{% endeditable %}
{% endif %}-->
+ {{ linked_organization_content.all }}
{% if linked_organization_content and research_slug == page.departmentpage.slug %}
- {% include 'core/inc/linked_organization_content.html' %}
+ {% include 'pages/page/includes/linked_organization_content.html' %}
{% endif %}
{% if page.departmentpage.content %}
--- /dev/null
+{% load organization_tags %}
+<div class="row">
+ <div class="pull-right">
+ <ul class="linked-organizations">
+ {% for loc in linked_organization_content %}
+ {% if loc.images.all %}
+ {% with loc.images|get_type:"logo_black"|first as img %}
+ <li class="linked-organizations__item">
+ <a href="{{ loc.url }}" title="{{ loc.title }}" target="_blank">
+ <img src="{{ MEDIA_URL }}{{ img }}" title="{{ img.title }}" />
+ </a>
+ </li>
+ {% endwith %}
+ {% endif %}
+ {% endfor %}
+ </ul>
+ </div>
+</div>
--- /dev/null
+{% load organization_tags %}
+{% for lof in linked_organization_footer %}
+ {% if lof.images.all %}
+ <a href="{{ lof.url }}" target="_blank" title="{{ lof.name }}">
+ {% with lof.images|get_type:"logo_white"|first as img %}
+ <img class="footer__partner" src="{{ MEDIA_URL }}{{ img }}" title="{{ img.title }}" width="120" height="66" />
+ {% endwith %}
+ </a>
+ {% endif %}
+{% endfor %}
--- /dev/null
+{% load organization_tags %}
+<ul class="unstyled-list">
+ {% for lof in linked_organization_footer_2 %}
+ <li>
+ <a class="footer__link" href="{{ lof.url }}" target="_blank" title="{{ lof.name }}">{{ lof.name}} </a>
+ </li>
+ {% endfor %}
+</ul>
{% block page_content %}
{% with page.get_ascendants|last as top_level_parent %}
{% if linked_organization_content and research_slug == top_level_parent.slug %}
- {% include 'core/inc/linked_organization_content.html' %}
+ {% include 'pages/page/includes/linked_organization_content.html' %}
{% endif %}
{% endwith %}
{% block page_content %}
{% with page.get_ascendants|last as top_level_parent %}
{% if linked_organization_content and research_slug == top_level_parent.slug %}
- {% include 'core/inc/linked_organization_content.html' %}
+ {% include 'pages/page/includes/linked_organization_content.html' %}
{% endif %}
{% endwith %}
{% if page.teampage.sub_title %}
{% with page.get_ascendants|last as top_level_parent %}
{% if linked_organization_content and research_slug == top_level_parent.slug %}
- {% include 'core/inc/linked_organization_content.html' %}
+ {% include 'pages/page/includes/linked_organization_content.html' %}
{% endif %}
{% endwith %}