]> git.parisson.com Git - mezzo.git/commitdiff
[Person] : events and other objects
authorEmilie <zawadzki@ircam.fr>
Wed, 15 Feb 2017 10:08:56 +0000 (11:08 +0100)
committerEmilie <zawadzki@ircam.fr>
Wed, 15 Feb 2017 10:08:56 +0000 (11:08 +0100)
app/organization/network/views.py
app/templates/network/person_detail.html

index 9e6ca5e6a4d530eab6eea3b745dff74919a4f794..10d5aaa51e9128a1057ccba725cee979f7d56130 100644 (file)
@@ -59,7 +59,7 @@ class PersonDetailView(SlugMixin, DetailView):
         context["related"]["event"] = events
         # All other related models
         person_list_block_inlines = self.object.person_list_block_inlines.all()
-        related_instances = []
+        context["related"]["other"] = []
         # for each person list to which the person belongs to...
         for person_list_block_inline in person_list_block_inlines:
             related_objects = person_list_block_inline.person_list_block._meta.get_all_related_objects()
@@ -76,10 +76,9 @@ class PersonDetailView(SlugMixin, DetailView):
                                     instance = getattr(related_inline, field.name)
                                     # get only article, custom page etc...
                                     if not isinstance(instance, person_list_block_inline.person_list_block.__class__) :  #and not isinstance(person_list_block_inline.person_list_block.__class__):
-                                        if not instance._meta.model_name in context["related"]:
-                                            context["related"][instance._meta.model_name] = []
-                                        context["related"][instance._meta.model_name].append(instance)
+                                        context["related"]["other"].append(instance)
 
+        context["related"]["other"].sort(key=lambda x: x.created, reverse=True)
         context["person_email"] = self.object.email if self.object.email else self.object.slug.replace('-', '.')+" (at) ircam.fr"
         return context
 
index c2d6cb88fe39cfeda2b19461d904c9e04fb7e91f..537f09ea803e92e17ba47eb8f41ca8c3e4a868eb 100644 (file)
         {{ event }}<br>
     {% endfor %}
 
-    <h2>{% trans 'Related Articles' %}</h2>
-    {% for article in related.article %}
-        {{ article }}<br>
-    {% endfor %}
-
-    <h2>{% trans 'Related Pages' %}</h2>
-    {% for custompage in related.custompage %}
-        {{ custompage }}<br>
+    <h2>{% trans 'Related Content' %}</h2>
+    {% for other in related.other %}
+        {{ other }}<br>
     {% endfor %}
 
 {% endblock %}