#searchform fieldset {\r
padding: 0;\r
padding: .5em;\r
- width: 450px;\r
+ width: 650px;\r
border: none;\r
border: 1px dotted #888;\r
margin-bottom: 1em;\r
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-02-12 14:31+0100\n"
+"POT-Creation-Date: 2010-02-15 17:49+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Olivier Guilyardi <olivier samalyse com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "publisher"
msgstr "éditeur"
-#: models/enum.py:134 models/enum.py:145 models/instrument.py:41
+#: models/enum.py:134 models/enum.py:146 models/instrument.py:41
#: models/instrument.py:51 models/location.py:50 models/location.py:142
#: models/media.py:347
msgid "name"
msgstr "nom"
-#: models/enum.py:144 models/media.py:225
+#: models/enum.py:138 models/enum.py:145 models/media.py:225
msgid "population / social group"
msgstr "population / groupe social"
msgid "current location"
msgstr "lieu actuel"
-#: models/location.py:57 models/location.py:151
+#: models/location.py:57 models/location.py:151 models/location.py:165
msgid "authoritative"
msgstr "officiel"
msgstr "Recherche"
#: templates/telemeta_default/base.html:34
+#: templates/telemeta_default/search_criteria.html:53
msgid "Advanced search"
msgstr "Recherche avancée"
msgstr "Mentions légales"
#: templates/telemeta_default/collection_detail.html:77
-#: templates/telemeta_default/inc/collection_list.html:16
-#: templates/telemeta_default/inc/mediaitem_list.html:15
+#: templates/telemeta_default/inc/collection_list.html:17
+#: templates/telemeta_default/inc/mediaitem_list.html:16
msgid "Recordist"
msgstr "Enregistré par"
msgstr "Liste"
#: templates/telemeta_default/geo_continents.html:24
-#: templates/telemeta_default/index.html:8
+#: templates/telemeta_default/index.html:9
msgid "Geographic Navigator"
msgstr "Navigateur géographique"
msgid "World"
msgstr "Monde"
-#: templates/telemeta_default/index.html:10
+#: templates/telemeta_default/index.html:11
msgid "Open the geographic navigator"
msgstr "Accéder au navigateur géographique"
-#: templates/telemeta_default/index.html:13
+#: templates/telemeta_default/index.html:14
msgid "Musical selection"
msgstr "Sélection musicale"
msgstr "Date d'enregistrement"
#: templates/telemeta_default/mediaitem_detail.html:147
-#: templates/telemeta_default/inc/mediaitem_list.html:17
+#: templates/telemeta_default/inc/mediaitem_list.html:18
msgid "Location"
msgstr "Lieu"
msgid "No such item"
msgstr "Item introuvable"
-#: templates/telemeta_default/inc/collection_list.html:6
-#, python-format
-msgid "Collections %(first_on_page)s to %(last_on_page)s on %(hits)s"
-msgstr "Collections %(first_on_page)s à %(last_on_page)s sur %(hits)s"
-
+#: templates/telemeta_default/search_criteria.html:87
#: templates/telemeta_default/inc/collection_list.html:14
#: templates/telemeta_default/inc/mediaitem_list.html:14
msgid "Title"
msgstr "Titre"
-#: templates/telemeta_default/inc/collection_list.html:17
-#: templates/telemeta_default/inc/mediaitem_list.html:21
+#: templates/telemeta_default/search_criteria.html:93
+#: templates/telemeta_default/search_results.html:29
+#: templates/telemeta_default/inc/collection_list.html:18
+#: templates/telemeta_default/inc/mediaitem_list.html:22
msgid "Year of recording"
msgstr "Année d'enregistrement"
-#: templates/telemeta_default/inc/collection_list.html:38
+#: templates/telemeta_default/search_criteria.html:100
+#: templates/telemeta_default/search_criteria.html:119
+#: templates/telemeta_default/search_results.html:31
+#: templates/telemeta_default/search_results.html:38
+msgid "to"
+msgstr "à"
+
+#: templates/telemeta_default/search_criteria.html:112
+#: templates/telemeta_default/search_results.html:36
+msgid "Year of issue"
+msgstr "Année de parution"
+
+#: templates/telemeta_default/search_results.html:6
+msgid "Search results"
+msgstr "Résultats de recherche"
+
+#: templates/telemeta_default/search_results.html:11
+msgid "Search pattern"
+msgstr "Recherche"
+
+#: templates/telemeta_default/inc/collection_list.html:6
+#, python-format
+msgid "Collections %(first_on_page)s to %(last_on_page)s on %(hits)s"
+msgstr "Collections %(first_on_page)s à %(last_on_page)s sur %(hits)s"
+
+#: templates/telemeta_default/inc/collection_list.html:15
+#: templates/telemeta_default/inc/mediaitem_list.html:15
+msgid "Code"
+msgstr "Cote"
+
+#: templates/telemeta_default/inc/collection_list.html:42
msgid "No collection"
msgstr "Aucune collection"
msgid "Items %(first_on_page)s to %(last_on_page)s on %(hits)s"
msgstr "Items %(first_on_page)s à %(last_on_page)s sur %(hits)s"
-#: templates/telemeta_default/inc/mediaitem_list.html:19
+#: templates/telemeta_default/inc/mediaitem_list.html:20
msgid "Country/Continent"
msgstr "Pays/Continent"
-#: templates/telemeta_default/inc/mediaitem_list.html:46
+#: templates/telemeta_default/inc/mediaitem_list.html:50
msgid "No item"
msgstr "Aucun item"
-#: templatetags/telemeta_utils.py:200
+#: templatetags/telemeta_utils.py:203
#, python-format
msgid "%(count)d item"
msgid_plural "%(count)d items"
msgstr[0] "%(count)d item"
msgstr[1] "%(count)d items"
-#: templatetags/telemeta_utils.py:203
+#: templatetags/telemeta_utils.py:206
#, python-format
msgid "%(count)d collection"
msgid_plural "%(count)d collections"
from telemeta.models.instrument import *
from telemeta.models.enum import *
from telemeta.models.system import *
-#MediaCollection, MediaItem, MediaPart, Revision, \
-# PhysicalFormat, PublishingStatus
__all__ = ['ModelCore', 'MetaCore', 'DurationField', 'Duration', 'WeakForeignKey',
'EnhancedModel', 'CharField', 'TextField', 'IntegerField', 'BooleanField',
'DateTimeField', 'FileField', 'ForeignKey', 'FloatField', 'DateField',
- 'RequiredFieldError', 'CoreQuerySet', 'CoreManager']
+ 'RequiredFieldError', 'CoreQuerySet', 'CoreManager', 'word_search_q']
from django.core import exceptions
from django import forms
class MetaCore:
app_label = 'telemeta'
+def word_search_q(field, pattern):
+ words = re.split("[ .*-]+", pattern)
+ q = Q()
+ for w in words:
+ if len(w) >= 3:
+ kwargs = {field + '__icontains': w}
+ q &= Q(**kwargs)
+
+ return q
+
class CoreQuerySet(EnhancedQuerySet):
"Base class for all query sets"
"Return an empty result set"
return self.extra(where = ["0 = 1"])
- def word_search_q(self, field, pattern):
- words = re.split("[ .*-]+", pattern)
- q = Q()
- for w in words:
- if len(w) >= 3:
- kwargs = {field + '__icontains': w}
- q &= Q(**kwargs)
-
- return q
-
def word_search(self, field, pattern):
- return self.filter(self.word_search_q(field, pattern))
+ return self.filter(word_search_q(field, pattern))
def _by_change_time(self, type, from_time = None, until_time = None):
"Search between two revision dates"
"Base class for all media item query sets"
def quick_search(self, pattern):
- "Perform a quick search on id and title"
+ "Perform a quick search on code, title and collector name"
+ pattern = pattern.strip()
return self.filter(
- self.word_search_q('id', pattern) |
- self.word_search_q('title', pattern) |
- self.word_search_q('author', pattern)
+ Q(code__contains=pattern.strip()) |
+ Q(old_code__contains=pattern.strip()) |
+ word_search_q('title', pattern) |
+ self.by_fuzzy_collector_q(pattern)
)
def without_collection(self):
def by_title(self, pattern):
"Find items by title"
# to (sort of) sync with models.media.MediaItem.get_title()
- return self.filter(self.word_search_q("title", pattern) | self.word_search_q("collection__title", pattern))
+ return self.filter(word_search_q("title", pattern) |
+ (Q(title="") & word_search_q("collection__title", pattern)))
def by_publish_year(self, from_year, to_year = None):
"Find items by publishing year"
ids = self.filter(ethnic_group__isnull=False).values('ethnic_group');
return EthnicGroup.objects.filter(pk__in=ids).order_by('name')
+ @staticmethod
+ def by_fuzzy_collector_q(pattern):
+ return (word_search_q('collection__creator', pattern) |
+ word_search_q('collection__collector', pattern) |
+ word_search_q('collector', pattern))
+
+ def by_fuzzy_collector(self, pattern):
+ return self.filter(self.by_fuzzy_collector_q(pattern))
+
class MediaItemManager(CoreManager):
"Manage media items queries"
class MediaCollectionQuerySet(CoreQuerySet):
def quick_search(self, pattern):
- "Perform a quick search on id, title and creator name"
+ "Perform a quick search on code, title and collector name"
+ pattern = pattern.strip()
return self.filter(
- self.word_search_q('id', pattern) |
- self.word_search_q('title', pattern) |
- self.word_search_q('creator', pattern)
+ Q(code__contains=pattern.strip()) |
+ Q(old_code__contains=pattern.strip()) |
+ word_search_q('title', pattern) |
+ self.by_fuzzy_collector_q(pattern)
)
def by_location(self, location):
to_min = self.filter(recorded_to_year__gt=0).aggregate(Min('recorded_to_year'))['recorded_to_year__min']
year_min = min(from_min, to_min)
+ if not year_max:
+ year_max = year_min
+ elif not year_min:
+ year_min = year_max
+
+ return year_min, year_max
+
+ def publishing_year_range(self):
+ year_max = self.aggregate(Max('year_published'))['year_published__max']
+ year_min = self.filter(year_published__gt=0).aggregate(Min('year_published'))['year_published__min']
+
return year_min, year_max
+ @staticmethod
+ def by_fuzzy_collector_q(pattern):
+ return word_search_q('creator', pattern) | word_search_q('collector', pattern)
+
+ def by_fuzzy_collector(self, pattern):
+ return self.filter(self.by_fuzzy_collector_q(pattern))
+
class MediaCollectionManager(CoreManager):
"Manage collection queries"
<table class="listing">
<tr>
<th class="highlight">{% trans "Title" %}</th>
+ <th>{% trans "Code" %}</th>
<th>{% field_label "MediaCollection" "creator" %}</th>
<th>{% trans "Recordist" %}</th>
<th>{% trans "Year of recording" %}</th>
<td class="highlight">
<a href="{% url telemeta-collection-detail collection.public_id %}">{{ collection }}</a>
</td>
+ <td>
+ {{ collection.code|default:collection.old_code }}
+ </td>
<td>{{ collection.creator }}</td>
<td>{{ collection.apparent_collector }}</td>
<td>
<table class="listing">
<tr>
<th class="highlight">{% trans "Title" %}</th>
+ <th>{% trans "Code" %}</th>
<th>{% trans "Recordist" %}</th>
{% if location_name %}
<th>{% trans "Location" %}</th>
<td class="highlight">
<a href="{% url telemeta-item-detail item.public_id %}">{{ item }}</a>
</td>
+ <td>
+ {{ item.code|default:item.old_code }}
+ </td>
<td>{{ item.apparent_collector }}</td>
{% if location_name %}
<td>{{ item.location.name }}</td>
{% block extra_javascript %}
<script src="{% url telemeta-js "jquery.autocomplete.js" %}" type="text/javascript"></script>
<script type="text/javascript">
-function update_rec_period() {
- var from_year = $('#rec_year_from');
- var to_year = $('#rec_year_to');
+function update_period(from_field, to_field) {
+ var from_year = $(from_field);
+ var to_year = $(to_field);
if (from_year.val() == "0") {
to_year.attr('disabled', '1');
return data[0].replace(/ *\([0-9]+.*\) *$/, '');
}
});
- update_rec_period();
- $('#rec_year_from, #rec_year_to').change(update_rec_period);
+ update_period('#rec_year_from', '#rec_year_to');
+ $('#rec_year_from, #rec_year_to').change(function () {
+ update_period('#rec_year_from', '#rec_year_to');
+ });
+ update_period('#pub_year_from', '#pub_year_to');
+ $('#pub_year_from, #pub_year_to').change(function () {
+ update_period('#pub_year_from', '#pub_year_to');
+ });
});
</script>
{% endblock %}
{% block content %}
-<h3>Advanced search</h3>
+<h3>{% trans "Advanced search" %}</h3>
<form action="{% url telemeta-search %}" id="searchform">
<fieldset>
<fieldset>
<p>
- <label for="creator">Creator</label>
+ <label for="title">{% trans "Title" %}</label>
+ <input type="text" id="title" name="title" />
+ </p>
+
+ <p>
+ <label for="creator">{% field_label "MediaCollection" "creator" %}</label>
<input type="text" id="creator" name="creator" />
</p>
<p>
- <label for="title">Title</label>
- <input type="text" id="title" name="title" />
+ <label for="collector">{% field_label "MediaCollection" "collector" %}</label>
+ <input type="text" id="collector" name="collector" />
</p>
{% if rec_years %}
<p>
- <label for="rec_date">{% trans "Year of recording" %}</label>
+ <label for="rec_date_from">{% trans "Year of recording" %}</label>
<select id="rec_year_from" name="rec_year_from" class="tiny">
<option value="0"></option>
{% for year in rec_years %}
</p>
{% endif %}
+ {% if pub_years %}
<p>
- <label for="pub_date">Publishing date</label>
- <input type="text" id="pub_date" name="pub_date" />
+ <label for="pub_date_from">{% trans "Year of issue" %}</label>
+ <select id="pub_year_from" name="pub_year_from" class="tiny">
+ <option value="0"></option>
+ {% for year in pub_years %}
+ <option value="{{ year }}" {% ifequal criteria.pub_year_from year %}selected {% endifequal %}>{{year}}</option>
+ {% endfor %}
+ </select>
+ {% trans "to" %}
+ <select id="pub_year_to" name="pub_year_to" class="tiny">
+ <option value="0"></option>
+ {% for year in pub_years %}
+ <option value="{{ year }}" {% ifequal criteria.pub_year_to year %}selected {% endifequal %}>{{year}}</option>
+ {% endfor %}
+ </select>
</p>
+ {% endif %}
</fieldset>
{% load i18n %}
{% block content %}
-<h3>Search results</h3>
+<h3>{% trans "Search results" %}</h3>
{% if criteria %}
<ul>
<li><b>{% trans "Search pattern" %}:</b> {{criteria.pattern}}</li>
{% endif %}
{% if criteria.location %}
- <li><b>{% field_label "Location" %}</b>: {{criteria.location}}</li>
+ <li><b>{% field_label "Location" %}:</b> {{criteria.location}}</li>
{% endif %}
{% if criteria.ethnic_group %}
<li><b>{% field_label "EthnicGroup" %}:</b> {{criteria.ethnic_group}}</li>
{% endif %}
{% if criteria.creator %}
- <li><b>Creator:</b> {{criteria.creator}}</li>
+ <li><b>{% field_label "MediaCollection" "creator" %}:</b> {{criteria.creator}}</li>
+ {% endif %}
+ {% if criteria.collector %}
+ <li><b>{% field_label "MediaCollection" "collector" %}:</b> {{criteria.collector}}</li>
{% endif %}
{% if criteria.title %}
<li><b>Title:</b> {{criteria.title}}</li>
{% endifnotequal %}
</li>
{% endif %}
- {% if criteria.pub_date %}
- <li><b>Publishing date:</b> {{criteria.pub_date}}</li>
+ {% if criteria.pub_year_from %}
+ <li><b>{% trans "Year of issue" %}:</b> {{criteria.pub_year_from}}
+ {% ifnotequal criteria.pub_year_to criteria.pub_year_from %}
+ {% trans "to" %} {{criteria.pub_year_to}}
+ {% endifnotequal %}
+ </li>
{% endif %}
</ul>
{% endif %}
def edit_search(self, request, criteria=None):
year_min, year_max = MediaCollection.objects.all().recording_year_range()
- years = year_min and year_max and range(year_min, year_max + 1) \
- or year_min and [year_min] or year_max and [year_max]
+ rec_years = year_min and year_max and range(year_min, year_max + 1) or []
+ year_min, year_max = MediaCollection.objects.all().publishing_year_range()
+ pub_years = year_min and year_max and range(year_min, year_max + 1) or []
return render_to_response('telemeta/search_criteria.html', {
- 'rec_years': years,
+ 'rec_years': rec_years,
+ 'pub_years': pub_years,
'ethnic_groups': MediaItem.objects.all().ethnic_groups(),
'criteria': criteria
})
EthnicGroup.objects.get(pk=value)),
'creator': lambda value: (
collections.word_search('creator', value),
- items.word_search('auteur', value)),
+ items.word_search('collection__creator', value)),
+ 'collector': lambda value: (
+ collections.by_fuzzy_collector(value),
+ items.by_fuzzy_collector(value)),
'rec_year_from': lambda value: (
- collections.by_recording_year(int(value), int(input['rec_year_to'])),
+ collections.by_recording_year(int(value), int(input.get('rec_year_to', value))),
items.by_recording_date(datetime.date(int(value), 1, 1),
- datetime.date(int(input['rec_year_to']), 12, 31))),
+ datetime.date(int(input.get('rec_year_to', value)), 12, 31))),
'rec_year_to': lambda value: (collections, items),
- 'pub_date': lambda value: (
- collections.by_publish_date(value),
- items.by_publish_date(value))
+ 'pub_year_from': lambda value: (
+ collections.by_publish_year(int(value), int(input.get('pub_year_to', value))),
+ items.by_publish_year(int(value), int(input.get('pub_year_to', value)))),
+ 'pub_year_to': lambda value: (collections, items),
}
for key, value in input.items():
func = switch.get(key)
- if func and value:
+ if func and value and value != "0":
res = func(value)
if len(res) > 2:
collections, items, value = res
collections, items = res
criteria[key] = value
+ print collections.query
+
if type is None:
if collections.count() and not items.count():
type = 'collections'