]> git.parisson.com Git - mezzo.git/commitdiff
Fix person detail data (fix #383)
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 9 Nov 2016 15:18:04 +0000 (16:18 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 9 Nov 2016 15:18:04 +0000 (16:18 +0100)
app/organization/core/templatetags/organization_tags.py
app/templates/network/person_detail.html
app/templates/network/person_detail_multiple_activities.html [new file with mode: 0644]

index 0653b547b59a380fac5712dd7b107a471e900e0e..e232532ef107bde3ab491407f9edb6a9409554e8 100644 (file)
@@ -166,3 +166,7 @@ def date_year_higher_than(date, years):
 @register.simple_tag
 def current_year():
     return datetime.datetime.now().strftime("%Y")
+
+@register.filter
+def is_not_host(organizations):
+    return organizations.exclude(is_host=True)
index 0562294bf59964898d592339fdae6a197d3994f5..1cb88b2ae053251b4e1f6f4ca3d82844c3faa725 100644 (file)
 
     <p><strong>{% trans 'Email' %} :</strong> {{ person_email }}</p>
 
-    {% if person.activities.all|length > 0 %}
-        <h2 class="dotted">{% trans 'Activities' %}</h2>
+    {% with person.activities.all as activities %}
+      {% if activities %}
+        {# <h2 class="dotted">{% trans 'Activities' %}</h2>#}
         <ul class="unstyled-list">
-            {% for activity in person.activities.all %}
+          {% with activities.0 as activity %}
             <li class="mb1">
-                {% comment %}
-                {% if activity.function %}
-                    <strong>{% trans 'Function'%} : </strong>{{ activity.function }}<br>
-                {% endif %}
-                {% if activity.status %}
-                    <strong>{% trans 'Status'%} : </strong>{{ activity.status }}<br>
-                {% endif %}
-                {% endcomment %}
                 {% with activity.teams.all as teams %}
+                 {% with activity.organizations.all|is_not_host as organizations %}
+                  {% with activity.employers.all|is_not_host as employers %}
                     {% if teams %}
                         <strong>{% trans 'Team' %} : </strong>
                         {% for team in teams %}
-                            <a href="{% url "page" team.pages.all.0 %}">{{ team.name }}</a>{% if not forloop.last %}, {% endif %}
+                            <a href="{% url "page" team.pages.all.0 %}">{{ team.name }}</a>
+                            {% if organizations %}({% for organization in organizations %}{{ organization.name }}{% if not forloop.last %}, {% endif %}{% endfor %})
+                            {% elif employers %}({% for employer in employers %}{{ employer.name }}{% if not forloop.last %}, {% endif %}{% endfor %}){% endif %}
+                            <br />
                         {% endfor %}
-                        <br />
-                    {% endif %}
-                {% endwith %}
-                {% with activity.organizations.all as organizations %}
-                  {% with activity.employers.all as employers %}
-                    {% if organizations %}
-                        <strong>{% trans 'Organization' %} : </strong>
-                        {% for organization in organizations %}
-                            {{ organization.name }}{% if not forloop.last %}, {% endif %}
-                        {% endfor %}
-                        <br />
-                    {% elif employers %}
-                        <strong>{% trans 'Organization' %} : </strong>
-                        {% for employer in employers %}
-                            {{ employer.name }}{% if not forloop.last %}, {% endif %}
-                        {% endfor %}
-                    <br />
                     {% endif %}
+                   {% endwith %}
                   {% endwith %}
                 {% endwith %}
-                {% if activity.date_from or activity.date_to %}
-                  {% if not activity.date_from and not activity.date_to|date_year_higher_than:10 %}
-                    <strong>{% trans 'Period' %}</strong> : {% trans 'to' %} {{ activity.date_to }}<br>
-                  {% elif not activity.date_to %}
-                    <strong>{% trans 'Period'%}</strong> : {% trans 'from' %} {{ activity.date_from }}<br>
-                  {% else %}
-                    <strong>{% trans 'Period'%}</strong> : {% trans 'from' %} {{ activity.date_from }} {% if not activity.date_to|date_year_higher_than:10 %}{% trans 'to' %} {{ activity.date_to }}{% endif %}<br>
-                  {% endif %}
-                {% endif %}
             </li>
-            {% endfor %}
+          {% endwith %}
         </ul>
-    {% endif %}
+      {% endif %}
+    {% endwith %}
 {% endblock %}
 
 {% block page_sidebar %}
 
 {% block page_link %}
     {% with person.links.all as links %}
-        {% if links or person_email %}
+        {% if links %}
             <h2 class="dotted">{% trans 'Links' %}</h2>
             {% include 'core/inc/link.html' %}
         {% endif %}
diff --git a/app/templates/network/person_detail_multiple_activities.html b/app/templates/network/person_detail_multiple_activities.html
new file mode 100644 (file)
index 0000000..0562294
--- /dev/null
@@ -0,0 +1,109 @@
+{% extends "pages/page.html" %}
+{% load mezzanine_tags keyword_tags i18n organization_tags pages_tags %}
+
+{% block meta_title %}{{ person.meta_title }}{% endblock %}
+
+{% block meta_keywords %}{% metablock %}
+{% keywords_for person as keywords %}
+{% for keyword in keywords %}
+    {% if not forloop.first %}, {% endif %}
+    {{ keyword }}
+{% endfor %}
+{% endmetablock %}{% endblock %}
+
+{% block page_class %}
+    person
+{% endblock %}
+
+{% block breadcrumb_menu %}
+    {{ block.super }}
+    <li class="breadcrumb__item active">{{ person }}</li>
+{% endblock %}
+
+{% block page_title %}
+    {% editable person.title %}
+        <h1 class="dotted">{{ person.title }}</h1>
+    {% endeditable %}
+{% endblock %}
+
+{% block page_content %}
+    {% editable person.bio %}
+        {{ person.bio|richtext_filters|safe }}
+    {% endeditable %}
+
+    <p><strong>{% trans 'Email' %} :</strong> {{ person_email }}</p>
+
+    {% if person.activities.all|length > 0 %}
+        <h2 class="dotted">{% trans 'Activities' %}</h2>
+        <ul class="unstyled-list">
+            {% for activity in person.activities.all %}
+            <li class="mb1">
+                {% comment %}
+                {% if activity.function %}
+                    <strong>{% trans 'Function'%} : </strong>{{ activity.function }}<br>
+                {% endif %}
+                {% if activity.status %}
+                    <strong>{% trans 'Status'%} : </strong>{{ activity.status }}<br>
+                {% endif %}
+                {% endcomment %}
+                {% with activity.teams.all as teams %}
+                    {% if teams %}
+                        <strong>{% trans 'Team' %} : </strong>
+                        {% for team in teams %}
+                            <a href="{% url "page" team.pages.all.0 %}">{{ team.name }}</a>{% if not forloop.last %}, {% endif %}
+                        {% endfor %}
+                        <br />
+                    {% endif %}
+                {% endwith %}
+                {% with activity.organizations.all as organizations %}
+                  {% with activity.employers.all as employers %}
+                    {% if organizations %}
+                        <strong>{% trans 'Organization' %} : </strong>
+                        {% for organization in organizations %}
+                            {{ organization.name }}{% if not forloop.last %}, {% endif %}
+                        {% endfor %}
+                        <br />
+                    {% elif employers %}
+                        <strong>{% trans 'Organization' %} : </strong>
+                        {% for employer in employers %}
+                            {{ employer.name }}{% if not forloop.last %}, {% endif %}
+                        {% endfor %}
+                    <br />
+                    {% endif %}
+                  {% endwith %}
+                {% endwith %}
+                {% if activity.date_from or activity.date_to %}
+                  {% if not activity.date_from and not activity.date_to|date_year_higher_than:10 %}
+                    <strong>{% trans 'Period' %}</strong> : {% trans 'to' %} {{ activity.date_to }}<br>
+                  {% elif not activity.date_to %}
+                    <strong>{% trans 'Period'%}</strong> : {% trans 'from' %} {{ activity.date_from }}<br>
+                  {% else %}
+                    <strong>{% trans 'Period'%}</strong> : {% trans 'from' %} {{ activity.date_from }} {% if not activity.date_to|date_year_higher_than:10 %}{% trans 'to' %} {{ activity.date_to }}{% endif %}<br>
+                  {% endif %}
+                {% endif %}
+            </li>
+            {% endfor %}
+        </ul>
+    {% endif %}
+{% endblock %}
+
+{% block page_sidebar %}
+    {% if person.images.all %}
+        {% with person.images.all|get_type:'page_featured' as images %}
+            {% if images.first %}
+                <figure class="person-list-box__image">
+                    <img src="{{ MEDIA_URL }}{% thumbnail images.first 135 135 top=0.5 %}" alt="person"/>
+                </figure>
+            {% endif %}
+        {% endwith %}
+    {% endif%}
+{% endblock %}
+
+{% block page_link %}
+    {% with person.links.all as links %}
+        {% if links or person_email %}
+            <h2 class="dotted">{% trans 'Links' %}</h2>
+            {% include 'core/inc/link.html' %}
+        {% endif %}
+    {% endwith %}
+{% endblock %}