From: olivier <> Date: Tue, 9 Feb 2010 17:40:52 +0000 (+0000) Subject: show items and collections lists as tables X-Git-Tag: 1.1~558 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=619d1a8ddd52d7803c5db3de7dd710e8a0cad256;p=telemeta.git show items and collections lists as tables --- diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index 48f15542..a77ee55c 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -520,7 +520,6 @@ dl.dublincore dd.caption { margin-top: .7em; margin-bottom: .3em; padding: .3em 0; - float: left; font-size: .9em; background-color: #fff; border-bottom: 1px solid #aaa; @@ -563,8 +562,12 @@ table.instruments tbody td { table.listing { clear: both; border-spacing: 0; +} + +.fullpage table.listing { width: 100%; } + table.listing th { text-align: left; padding: 0 14em .1em 0; @@ -611,3 +614,5 @@ table.listing tbody tr { border-top: 1px solid #ddd } table.listing tbody tr.even { background-color: #fcfcfc } table.listing tbody tr.odd { background-color: #f7f7f7 } table.listing tbody tr:hover { background: #f7f8fa !important } + + diff --git a/telemeta/htdocs/js/application.js b/telemeta/htdocs/js/application.js index 22e5fffe..f94f4cd8 100644 --- a/telemeta/htdocs/js/application.js +++ b/telemeta/htdocs/js/application.js @@ -8,5 +8,7 @@ function foldInfoBlocks() { }); } -$(document).ready(foldInfoBlocks); +$(document).ready(function() { + foldInfoBlocks(); +}); diff --git a/telemeta/htdocs/js/resourcemap.js b/telemeta/htdocs/js/resourcemap.js index 0fcd16a5..b3fbdfda 100644 --- a/telemeta/htdocs/js/resourcemap.js +++ b/telemeta/htdocs/js/resourcemap.js @@ -76,6 +76,7 @@ function ResourceMap(list, cfg) { $.get(uri, function(data) { info.html(data); + //marker.openInfoWindowHtml(info.get(0)); }); } diff --git a/telemeta/locale/fr/LC_MESSAGES/django.po b/telemeta/locale/fr/LC_MESSAGES/django.po index 7e0c28f3..d7f681b8 100644 --- a/telemeta/locale/fr/LC_MESSAGES/django.po +++ b/telemeta/locale/fr/LC_MESSAGES/django.po @@ -205,8 +205,8 @@ msgid "location" msgstr "lieu" #: models/crem.py:296 -msgid "location comment" -msgstr "commentaire lieu" +msgid "location details" +msgstr "précisions lieu" #: models/crem.py:298 models/crem.py:710 msgid "population / social group" diff --git a/telemeta/models/crem.py b/telemeta/models/crem.py index 4c75f2a2..e80d8a0e 100755 --- a/telemeta/models/crem.py +++ b/telemeta/models/crem.py @@ -160,8 +160,8 @@ class MediaCollection(MediaResource): creator = CharField(_('depositor / contributor')) booklet_author = CharField(_('author of published notice')) booklet_description = TextField(_('related documentation')) - collector = CharField(_('collector')) - collector_is_creator = BooleanField(_('collector identical to depositor')) + collector = CharField(_('recordist')) + collector_is_creator = BooleanField(_('recordist identical to depositor')) publisher = WeakForeignKey('Publisher', related_name="collections", verbose_name=_('publisher / status')) is_published = BooleanField(_('published')) @@ -293,7 +293,7 @@ class MediaItem(MediaResource): recorded_from_date = DateField(_('recording date (from)')) recorded_to_date = DateField(_('recording date (until)')) location = WeakForeignKey('Location', verbose_name=_('location')) - location_comment = CharField(_('location comment')) + location_comment = CharField(_('location details')) ethnic_group = WeakForeignKey('EthnicGroup', related_name="items", verbose_name=_('population / social group')) title = CharField(_('title'), required=True) @@ -305,11 +305,12 @@ class MediaItem(MediaResource): external_references = TextField(_('published reference')) moda_execut = CharField(_('moda_execut')) copied_from_item = WeakForeignKey('self', related_name="copies", verbose_name=_('copy of')) - collector = CharField(_('recorded by')) + collector = CharField(_('recordist')) + collector_from_collection = BooleanField(_('recordist as in collection')) cultural_area = CharField(_('cultural area')) generic_style = WeakForeignKey('GenericStyle', related_name="items", verbose_name=_('generic name')) - collector_selection = CharField(_('collector selection')) + collector_selection = CharField(_('recordist selection')) creator_reference = CharField(_('reference')) comment = TextField(_('comment')) file = FileField(_('file'), upload_to='items/%Y/%m/%d', db_column="filename") diff --git a/telemeta/models/cremquery.py b/telemeta/models/cremquery.py index bb13949e..1165d7ba 100644 --- a/telemeta/models/cremquery.py +++ b/telemeta/models/cremquery.py @@ -105,13 +105,9 @@ class MediaCollectionQuerySet(CoreQuerySet): ) def by_location(self, location): - "Find collections by country" + "Find collections by location" return self.filter(Q(items__location=location) | Q(items__location__in=location.descendants())).distinct() - def by_continent(self, continent): - "Find collections by continent" - return self.filter(items__location__type="continent", items__location=continent).distinct() - def by_recording_year(self, from_year, to_year=None): "Find collections by recording year" if to_year is None: @@ -134,6 +130,17 @@ class MediaCollectionQuerySet(CoreQuerySet): "Find collections between two dates" return self._by_change_time('collection', from_time, until_time) + def virtual(self, *args): + qs = self + for f in args: + if f == 'apparent_collector': + qs = qs.extra(select={f: 'IF(media_collections.collector_is_creator, ' + 'media_collections.creator, media_collections.collector)'}) + else: + raise Exception("Unsupported virtual field: %s" % f) + + return qs + class MediaCollectionManager(CoreManager): "Manage collection queries" @@ -141,6 +148,10 @@ class MediaCollectionManager(CoreManager): "Return the collection query" return MediaCollectionQuerySet(self.model) + def enriched(self): + "Query set with additional virtual fields such as apparent_collector" + return self.get_query_set().virtual('apparent_collector') + def quick_search(self, *args, **kwargs): return self.get_query_set().quick_search(*args, **kwargs) quick_search.__doc__ = MediaCollectionQuerySet.quick_search.__doc__ @@ -149,10 +160,6 @@ class MediaCollectionManager(CoreManager): return self.get_query_set().by_location(*args, **kwargs) by_location.__doc__ = MediaCollectionQuerySet.by_location.__doc__ - def by_continent(self, *args, **kwargs): - return self.get_query_set().by_continent(*args, **kwargs) - by_continent.__doc__ = MediaCollectionQuerySet.by_continent.__doc__ - def by_recording_year(self, *args, **kwargs): return self.get_query_set().by_recording_year(*args, **kwargs) by_recording_year.__doc__ = MediaCollectionQuerySet.by_recording_year.__doc__ @@ -286,6 +293,43 @@ class MediaItemQuerySet(CoreQuerySet): return countries + def virtual(self, *args): + qs = self + need_collection = False + related = [] + for f in args: + if f == 'apparent_collector': + related.append('collection') + qs = qs.extra(select={f: + 'IF(collector_from_collection, ' + 'IF(media_collections.collector_is_creator, ' + 'media_collections.creator, ' + 'media_collections.collector),' + 'media_items.collector)'}) + elif f == 'country_or_continent': + from telemeta.models import Location + related.append('location') + qs = qs.extra(select={f: + 'IF(locations.type = ' + str(Location.COUNTRY) + ' ' + 'OR locations.type = ' + str(Location.CONTINENT) + ',' + 'locations.name, ' + '(SELECT l2.name FROM location_relations AS r INNER JOIN locations AS l2 ' + 'ON r.ancestor_location_id = l2.id ' + 'WHERE r.location_id = media_items.location_id AND l2.type = ' + str(Location.COUNTRY) + ' ))' + }) + else: + raise Exception("Unsupported virtual field: %s" % f) + + if related: + qs = qs.select_related(*related) + + return qs + + def ethnic_groups(self): + return self.filter(ethnic_group__isnull=False) \ + .values_list('ethnic_group__name', flat=True) \ + .distinct().order_by('ethnic_group__name') + class MediaItemManager(CoreManager): "Manage media items queries" @@ -293,6 +337,10 @@ class MediaItemManager(CoreManager): "Return media query sets" return MediaItemQuerySet(self.model) + def enriched(self): + "Query set with additional virtual fields such as apparent_collector and country_or_continent" + return self.get_query_set().virtual('apparent_collector', 'country_or_continent') + def quick_search(self, *args, **kwargs): return self.get_query_set().quick_search(*args, **kwargs) quick_search.__doc__ = MediaItemQuerySet.quick_search.__doc__ diff --git a/telemeta/templates/telemeta_default/base.html b/telemeta/templates/telemeta_default/base.html index 9685a7bc..d2beb6c6 100644 --- a/telemeta/templates/telemeta_default/base.html +++ b/telemeta/templates/telemeta_default/base.html @@ -12,6 +12,7 @@ {% endblock %} + {% block extra_javascript %}{% endblock %} {% load i18n %} diff --git a/telemeta/templates/telemeta_default/collection_detail.html b/telemeta/templates/telemeta_default/collection_detail.html index 8e18a3e6..bf95a9f6 100644 --- a/telemeta/templates/telemeta_default/collection_detail.html +++ b/telemeta/templates/telemeta_default/collection_detail.html @@ -3,7 +3,6 @@ {% load i18n %} {% block extra_javascript %} - {% endblock %} @@ -135,7 +134,7 @@ {% endblock technical_data %}
Collections {{ first_on_page }} to {{ last_on_page }} on {{ hits }} - - {% if has_previous %} << {% endif %} - {% if has_next %} >> {% endif %} -
- {% endif %} -Collections {{ first_on_page }} to {{ last_on_page }} on {{ hits }} + +{% if has_previous %} << {% endif %} +{% if has_next %} >> {% endif %} +
+{% endif %} +{% trans "Title" %} | +{% field_label "MediaCollection" "creator" %} | +{% trans "Recordist" %} | +
---|---|---|
+ {{ collection }} + | +{{ collection.creator }} | +{{ collection.apparent_collector }} | +
No collection
+{% trans "No collection" %}
{% endif %} + diff --git a/telemeta/templates/telemeta_default/inc/mediaitem_list.html b/telemeta/templates/telemeta_default/inc/mediaitem_list.html index a7ab7d71..8d8f5a73 100644 --- a/telemeta/templates/telemeta_default/inc/mediaitem_list.html +++ b/telemeta/templates/telemeta_default/inc/mediaitem_list.html @@ -1,18 +1,30 @@ {% load telemeta_utils %} +{% load i18n %} {% if items %} - {% if hits %} -Items {{ first_on_page }} to {{ last_on_page }} on {{ hits }} - - {% if has_previous %} << {% endif %} - {% if has_next %} >> {% endif %} -
- {% endif %} -Items {{ first_on_page }} to {{ last_on_page }} on {{ hits }} + +{% if has_previous %} << {% endif %} +{% if has_next %} >> {% endif %} +
+{% endif %} +{% trans "Title" %} | +{% trans "Recordist" %} | +{% trans "Country/Continent" %} | +
---|---|---|
+ {{ item }} + | +{{ item.apparent_collector }} | +{{ item.country_or_continent|default:' ' }} | +
No item
+{% trans "No item" %}
{% endif %} + diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index 001301b1..70277b47 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -10,7 +10,6 @@ {% endblock %} {% block extra_javascript %} - diff --git a/telemeta/templates/telemeta_default/mediaitem_list.html b/telemeta/templates/telemeta_default/mediaitem_list.html index 341d25d7..8a4a28fe 100644 --- a/telemeta/templates/telemeta_default/mediaitem_list.html +++ b/telemeta/templates/telemeta_default/mediaitem_list.html @@ -1,8 +1,13 @@ {% extends "telemeta/base.html" %} +{% load i18n %} +{% load telemeta_utils %} {% block content %}