margin-top: .7em;\r
margin-bottom: .3em;\r
padding: .3em 0;\r
- float: left;\r
font-size: .9em;\r
background-color: #fff;\r
border-bottom: 1px solid #aaa;\r
table.listing {\r
clear: both;\r
border-spacing: 0;\r
+}\r
+\r
+.fullpage table.listing {\r
width: 100%;\r
}\r
+\r
table.listing th {\r
text-align: left;\r
padding: 0 14em .1em 0;\r
table.listing tbody tr.even { background-color: #fcfcfc }\r
table.listing tbody tr.odd { background-color: #f7f7f7 }\r
table.listing tbody tr:hover { background: #f7f8fa !important }\r
+\r
+\r
});\r
}\r
\r
-$(document).ready(foldInfoBlocks);\r
+$(document).ready(function() {\r
+ foldInfoBlocks();\r
+});\r
\r
$.get(uri, function(data) {
info.html(data);
+ //marker.openInfoWindowHtml(info.get(0));
});
}
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"
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'))
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)
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")
)
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:
"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"
"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__
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__
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"
"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__
<![endif]-->
{% endblock %}
<script src="{% url telemeta-js "jquery.js" %}" type="text/javascript"></script>
+<script src="{% url telemeta-js "application.js" %}" type="text/javascript"></script>
{% block extra_javascript %}{% endblock %}
</head>
{% load i18n %}
{% load i18n %}\r
\r
{% block extra_javascript %}\r
-<script src="{% url telemeta-js "application.js" %}" type="text/javascript"></script>\r
<script src="{% url telemeta-js "swfobject.js" %}" type="text/javascript"></script>\r
{% endblock %}\r
\r
{% endblock technical_data %}\r
</div>\r
<h4>Items</h4>\r
- {% with collection.items.all as items %}\r
+ {% with collection.items.enriched as items %}\r
{% include "telemeta/inc/mediaitem_list.html" %}\r
{% endwith %}\r
<!--\r
<h3>Collections</h3>
{% with object_list as collections %}
+<div class="fullpage">
{% include "telemeta/inc/collection_list.html" %}
+</div>
{% endwith %}
{% endblock %}
{% load i18n %}
<h2>{{ country }}</h2>
+<p>
<a href="{% url telemeta-geo-country-items continent.flatname,country.flatname %}">
{{ country.items|resources_num }}
</a>
<a href="{% url telemeta-geo-country-collections continent.flatname,country.flatname %}">
{{ country.collections|resources_num }}
</a>
+</p>
+<!--
+{% with country.items.all.ethnic_groups as ethnic_groups %}
+{% if ethnic_groups %}
+<p>
+<b>{% trans "Populations / Social groups" %}:</b>
+{{ ethnic_groups|join:', ' }}
+</p>
+{% endif %}
+{% endwith %}
+-->
/ {{ country }}</h3>
{% with object_list as collections %}
+<div class="fullpage">
{% include "telemeta/inc/collection_list.html" %}
+</div>
{% endwith %}
{% endblock %}
/ {{ country }}</h3>
{% with object_list as items %}
+<div class="fullpage">
{% include "telemeta/inc/mediaitem_list.html" %}
+</div>
{% endwith %}
{% endblock %}
{% load telemeta_utils %}
+{% load i18n %}
{% if collections %}
- {% if hits %}
- <p class="pagination">Collections {{ first_on_page }} to {{ last_on_page }} on {{ hits }}
-
- {% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %}
- {% if has_next %} <a href="?page={{ next }}&{{criteria|build_query_string}}">>></a> {% endif %}
- </p>
- {% endif %}
- <ul>
- {% for p in collections %}
- <li><a href="{% url telemeta-collection-detail p.public_id %}">{{ p }}</a>
- </li>
- {% endfor %}
- {% if more_collections %} <li>[...]</li> {% endif %}
- </ul>
+{% if hits %}
+<p class="pagination">Collections {{ first_on_page }} to {{ last_on_page }} on {{ hits }}
+
+{% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %}
+{% if has_next %} <a href="?page={{ next }}&{{criteria|build_query_string}}">>></a> {% endif %}
+</p>
+{% endif %}
+<table class="listing">
+<tr>
+ <th class="highlight">{% trans "Title" %}</th>
+ <th>{% field_label "MediaCollection" "creator" %}</th>
+ <th>{% trans "Recordist" %}</th>
+</tr>
+{% for collection in collections %}
+<tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
+ <td class="highlight">
+ <a href="{% url telemeta-collection-detail collection.public_id %}">{{ collection }}</a>
+ </td>
+ <td>{{ collection.creator }}</td>
+ <td>{{ collection.apparent_collector }}</td>
+</tr>
+{% endfor %}
+</table>
{% else %}
- <p>No collection</p>
+ <p>{% trans "No collection" %}</p>
{% endif %}
+
{% load telemeta_utils %}
+{% load i18n %}
{% if items %}
- {% if hits %}
- <p class="pagination">Items {{ first_on_page }} to {{ last_on_page }} on {{ hits }}
-
- {% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %}
- {% if has_next %} <a href="?page={{ next }}&{{criteria|build_query_string}}">>></a> {% endif %}
- </p>
- {% endif %}
- <ul>
- {% for p in items %}
- <li><a href="{% url telemeta-item-detail p.public_id %}">{{ p }}</a></li>
- {% endfor %}
- {% if more_items %} <li>[...]</li> {% endif %}
- </ul>
+{% if hits %}
+<p class="pagination">Items {{ first_on_page }} to {{ last_on_page }} on {{ hits }}
+
+{% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %}
+{% if has_next %} <a href="?page={{ next }}&{{criteria|build_query_string}}">>></a> {% endif %}
+</p>
+{% endif %}
+<table class="listing">
+<tr>
+ <th class="highlight">{% trans "Title" %}</th>
+ <th>{% trans "Recordist" %}</th>
+ <th>{% trans "Country/Continent" %}</th>
+</tr>
+{% for item in items %}
+<tr {% if not forloop.counter0|divisibleby:"2" %}class="odd"{% endif %}>
+ <td class="highlight">
+ <a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>
+ </td>
+ <td>{{ item.apparent_collector }}</td>
+ <td>{{ item.country_or_continent|default:' ' }}</td>
+</tr>
+{% endfor %}
+</table>
{% else %}
- <p>No item</p>
+ <p>{% trans "No item" %}</p>
{% endif %}
+
{% endblock %}\r
{% block extra_javascript %}\r
\r
-<script src="{% url telemeta-js "application.js" %}" type="text/javascript"></script>\r
<script src="{% url telemeta-js "wz_jsgraphics.js" %}" type="text/javascript"></script>\r
<script src="{% url telemeta-js "soundmanager2.js" %}" type="text/javascript"></script>\r
<script src="{% url telemeta-timeside "src/timeside.js" %}" type="text/javascript"></script>\r
{% extends "telemeta/base.html" %}
+{% load i18n %}
+{% load telemeta_utils %}
{% block content %}
<h3>Media items</h3>
{% with object_list as items %}
+<div class="fullpage">
{% include "telemeta/inc/mediaitem_list.html" %}
+</div>
{% endwith %}
+
{% endblock %}
return capfirst(unicode(model.field_label(field)))
+@register.simple_tag
+def field_value(object, member):
+ value = getattr(object, member)
+ try:
+ value = value()
+ except TypeError:
+ pass
+ return value
+
@register.filter
def is_none(value):
return value is None
return label
+@register.filter
+def split(value, sep=','):
+ return value.split(sep)
+
+@register.simple_tag
+def variable_link(object, url_name, url_key):
+ return reverse(url_name, args=[field_value(object, url_key)])
web_view = WebView(comp_mgr)
# query sets for Django generic views
-all_items = { 'queryset': MediaItem.objects.all(), }
-all_collections = { 'queryset': MediaCollection.objects.all(), }
+all_items = { 'queryset': MediaItem.objects.enriched(), }
+all_collections = { 'queryset': MediaCollection.objects.enriched(), }
# ID's regular expressions
export_extensions = "|".join(web_view.list_export_extensions())
def list_country_collections(self, request, continent, country):
continent = Location.objects.by_flatname(continent)[0]
country = Location.objects.by_flatname(country)[0]
- objects = MediaCollection.objects.by_location(country)
+ objects = MediaCollection.objects.enriched().by_location(country)
return list_detail.object_list(request, objects,
template_name='telemeta/geo_country_collections.html', paginate_by=20,
extra_context={'country': country, 'continent': continent})
def list_country_items(self, request, continent, country):
continent = Location.objects.by_flatname(continent)[0]
country = Location.objects.by_flatname(country)[0]
- objects = MediaItem.objects.by_location(country)
+ objects = MediaItem.objects.enriched().by_location(country)
return list_detail.object_list(request, objects,
template_name='telemeta/geo_country_items.html', paginate_by=20,
extra_context={'country': country, 'continent': continent})