Changeset 551
- Timestamp:
- 02/15/10 12:47:10 (5 months ago)
- Location:
- trunk/telemeta
- Files:
-
- 5 modified
-
models/enum.py (modified) (1 diff)
-
models/query.py (modified) (3 diffs)
-
templates/telemeta_default/search_criteria.html (modified) (1 diff)
-
templates/telemeta_default/search_results.html (modified) (3 diffs)
-
web/base.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/telemeta/models/enum.py
r534 r551 136 136 class Meta(MetaCore): 137 137 db_table = 'ethnic_groups' 138 verbose_name = _('population / social group') 138 139 139 140 def __unicode__(self): -
trunk/telemeta/models/query.py
r535 r551 37 37 from telemeta.models.core import * 38 38 from telemeta.util.unaccent import unaccent, unaccent_icmp 39 from telemeta.models.enum import EthnicGroup 39 40 import re 40 41 … … 155 156 156 157 def ethnic_groups(self): 157 return self.filter(ethnic_group__isnull=False) \ 158 .values_list('ethnic_group__name', flat=True) \ 159 .distinct().order_by('ethnic_group__name') 158 ids = self.filter(ethnic_group__isnull=False).values('ethnic_group'); 159 return EthnicGroup.objects.filter(pk__in=ids).order_by('name') 160 160 161 161 class MediaItemManager(CoreManager): … … 228 228 def by_ethnic_group(self, group): 229 229 "Find collections by ethnic group" 230 return self.filter(items__ethnic_group __name=group).distinct()230 return self.filter(items__ethnic_group=group).distinct() 231 231 232 232 def by_change_time(self, from_time=None, until_time=None): -
trunk/telemeta/templates/telemeta_default/search_criteria.html
r539 r551 35 35 36 36 <p> 37 <label for="ethnic_group"> Ethnic group</label>37 <label for="ethnic_group">{% field_label "EthnicGroup" %}</label> 38 38 <select id="ethnic_group" name="ethnic_group"> 39 39 <option value="">All ethnic groups</option> -
trunk/telemeta/templates/telemeta_default/search_results.html
r535 r551 1 1 {% extends "telemeta/base.html" %} 2 2 {% load telemeta_utils %} 3 {% load i18n %} 3 4 4 5 {% block content %} … … 8 9 <ul> 9 10 {% if criteria.pattern %} 10 <li><b> Pattern:</b> {{criteria.pattern}}</li>11 <li><b>{% trans "Search pattern" %}:</b> {{criteria.pattern}}</li> 11 12 {% endif %} 12 13 {% if criteria.location %} 13 <li><b> Location:</b>{{criteria.location}}</li>14 <li><b>{% field_label "Location" %}</b>: {{criteria.location}}</li> 14 15 {% endif %} 15 16 {% if criteria.ethnic_group %} 16 <li><b> Ethnic group:</b> {{criteria.ethnic_group}}</li>17 <li><b>{% field_label "EthnicGroup" %}:</b> {{criteria.ethnic_group}}</li> 17 18 {% endif %} 18 19 {% if criteria.creator %} … … 23 24 {% endif %} 24 25 {% if criteria.rec_date %} 25 <li><b> Recording date:</b> {{criteria.rec_date}}</li>26 <li><b>{% trans "Year of recording" %}:</b> {{criteria.rec_date}}</li> 26 27 {% endif %} 27 28 {% if criteria.pub_date %} -
trunk/telemeta/web/base.py
r544 r551 46 46 47 47 import telemeta 48 from telemeta.models import MediaItem, Location, MediaCollection 48 from telemeta.models import MediaItem, Location, MediaCollection, EthnicGroup 49 49 from telemeta.models import dublincore 50 50 from telemeta.core import Component, ExtensionPoint … … 168 168 169 169 def edit_search(self, request): 170 ethnic_groups = MediaItem.objects.all().ethnic_groups() 171 return render_to_response('telemeta/search_criteria.html', 172 {'ethnic_groups': ethnic_groups}) 170 171 return render_to_response('telemeta/search_criteria.html', { 172 'ethnic_groups': MediaItem.objects.all().ethnic_groups(), 173 }) 173 174 174 175 def complete_location(self, request, with_items=True): … … 209 210 'ethnic_group': lambda value: ( 210 211 collections.by_ethnic_group(value), 211 items.filter(ethnie_grsocial = value)), 212 items.filter(ethnic_group = value), 213 EthnicGroup.objects.get(pk=value)), 212 214 'creator': lambda value: ( 213 215 collections.word_search('creator', value), … … 222 224 223 225 for key, value in input.items(): 224 if key == 'continent' and input.get('country'):225 continue226 226 func = switch.get(key) 227 227 if func and value: 228 collections, items = func(value) 228 res = func(value) 229 if len(res) > 2: 230 collections, items, value = res 231 else: 232 collections, items = res 229 233 criteria[key] = value 230 234
