]> git.parisson.com Git - telemeta.git/commitdiff
do not print duplicate countries and ethnic groups on collection detail
authorolivier <>
Fri, 7 Mar 2008 15:54:23 +0000 (15:54 +0000)
committerolivier <>
Fri, 7 Mar 2008 15:54:23 +0000 (15:54 +0000)
telemeta/models/media.py
telemeta/templates/collection_detail.html

index 0273b48bccf8a1f807afdc30a3d11eb740b1285f..7e8ddb8b620c44d9fbb401044e56abaced2c4a8c 100644 (file)
@@ -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
index ed721e9f375e6a8b90e9b27b32d21de6674e1efe..29afc068fd60a593ba1538d106d4fec9dc7abe61 100644 (file)
@@ -68,8 +68,8 @@
             <h4 class="on"><a href="#">Données ethnographiques</a></h4>
             <div>
                 <dl class="listing">
-                <dt>État / Nation</dt><dd>{% for item in object.items.all %}{% if item.etat %}{{item.etat}}{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}</dd>
-                <dt>Ethnie / Groupe social</dt><dd>{% for item in object.items.all %}{% if item.ethnie_grsocial %}{{item.ethnie_grsocial}}{% if not forloop.last %}, {% endif %}{% endif %}{% endfor %}</dd>
+                <dt>État / Nation</dt><dd>{{object.get_countries|join:", "}}</dd>
+                <dt>Ethnie / Groupe social</dt><dd>{{ object.get_ethnic_groups|join:", " }}</dd>
                 <dt>Contexte de l’enregistrement</dt><dd>{{ object.terrain_ou_autre }}</dd>
                 </dl>
             </div>