From: olivier <> Date: Fri, 7 Mar 2008 15:54:23 +0000 (+0000) Subject: do not print duplicate countries and ethnic groups on collection detail X-Git-Tag: 1.1~853 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=dea760fb0ed2a9f54f1934e3ec6e0119611891d3;p=telemeta.git do not print duplicate countries and ethnic groups on collection detail --- diff --git a/telemeta/models/media.py b/telemeta/models/media.py index 0273b48b..7e8ddb8b 100644 --- a/telemeta/models/media.py +++ b/telemeta/models/media.py @@ -155,6 +155,22 @@ class MediaCollection(Model, MediaCore): def ordered_items(self): return self.items.order_by('id', '_title') + def get_countries(self): + countries = [] + items = self.items.order_by('etat') + for item in items: + if not item.etat in countries and item.etat: + countries.append(item.etat) + return countries + + def get_ethnic_groups(self): + groups = [] + items = self.items.order_by('ethnie_grsocial') + for item in items: + if not item.ethnie_grsocial in groups and item.ethnie_grsocial: + groups.append(item.ethnie_grsocial) + return groups + def __str__(self): #return self.title return self.id diff --git a/telemeta/templates/collection_detail.html b/telemeta/templates/collection_detail.html index ed721e9f..29afc068 100644 --- a/telemeta/templates/collection_detail.html +++ b/telemeta/templates/collection_detail.html @@ -68,8 +68,8 @@

Données ethnographiques

-
État / Nation
{% for item in object.items.all %}{% if item.etat %}{{item.etat}}{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}
-
Ethnie / Groupe social
{% for item in object.items.all %}{% if item.ethnie_grsocial %}{{item.ethnie_grsocial}}{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}
+
État / Nation
{{object.get_countries|join:", "}}
+
Ethnie / Groupe social
{{ object.get_ethnic_groups|join:", " }}
Contexte de l’enregistrement
{{ object.terrain_ou_autre }}