From: olivier <> Date: Mon, 8 Feb 2010 17:55:30 +0000 (+0000) Subject: (start to) fix displaying multiple location paths X-Git-Tag: 1.1~559 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=77d8b6f699e0d1155b0896d9c7f40872c6d183ec;p=telemeta.git (start to) fix displaying multiple location paths --- diff --git a/telemeta/models/crem.py b/telemeta/models/crem.py index cd9a4447..4c75f2a2 100755 --- a/telemeta/models/crem.py +++ b/telemeta/models/crem.py @@ -632,17 +632,23 @@ class Location(ModelCore): return None - def sequences(self): - sequence = [] + def paths(self): + #FIXME: need to handle multiple (polyhierarchical) paths + path = [] location = self while location: - sequence.append(location) - location = location.parent() - return sequence + path.append(location) + try: + location = location.ancestors(direct=True)[0] + except IndexError: + location = None + return [path] def fullnames(self): - - return u', '.join([unicode(l) for l in self.sequence()]) + names = [] + for path in self.paths(): + names.append(u', '.join([unicode(l) for l in path])) + return names class LocationType(ModelCore): "Location types" diff --git a/telemeta/models/dublincore.py b/telemeta/models/dublincore.py index a839e7f6..b59cca8e 100644 --- a/telemeta/models/dublincore.py +++ b/telemeta/models/dublincore.py @@ -211,7 +211,7 @@ def express_item(item): Element('publisher', settings.TELEMETA_ORGANIZATION), date, Date(item.collection.year_published, refinement='issued'), - Element('coverage', item.location.fullname(), 'spatial'), + Element.multiple('coverage', item.location.fullnames(), 'spatial'), Element('coverage', item.location_comment, 'spatial'), Element('rights', item.collection.legal_rights, 'license'), Element('rights', media_access_rights(item.collection), 'accessRights'), diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index 8cc58a93..001301b1 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -146,7 +146,7 @@ load_player({{ item.get_duration }});
{% if item.location %}
{% trans "Location" %}
-
{{ item.location.fullname }}
+
{{ item.location.fullnames|join:"
" }}
{% endif %} {% dl_field item "location_comment" %} {% dl_field item "cultural_area" %}