Changeset c1a2c1c for telemeta/web/base.py
- Timestamp:
- 02/10/10 19:25:21 (3 years ago)
- Branches:
- master, crem, crem2, dev, dev2, diadems, forma, generic, instru_search, lam, nlivemulti, production, release/1.4.4, security, social, storage, test, video
- Children:
- 12d665f
- Parents:
- 622588f
- git-author:
- olivier <> (02/10/10 19:25:21)
- git-committer:
- olivier <> (02/10/10 19:25:21)
- File:
-
- 1 edited
-
telemeta/web/base.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telemeta/web/base.py
r619d1a8 rc1a2c1c 162 162 163 163 def edit_search(self, request): 164 continents = MediaCollection.objects.list_continents() 165 countries = MediaCollection.objects.list_countries() 166 ethnic_groups = MediaItem.objects.list_ethnic_groups() 164 ethnic_groups = MediaItem.objects.all().ethnic_groups() 167 165 return render_to_response('telemeta/search_criteria.html', 168 {'continents': continents, 'countries': countries, 169 'ethnic_groups': ethnic_groups}) 166 {'ethnic_groups': ethnic_groups}) 167 168 def complete_location(self, request, with_items=True): 169 input = request.REQUEST 170 171 token = input['q'] 172 limit = int(input['limit']) 173 if with_items: 174 locations = MediaItem.objects.all().locations() 175 else: 176 locations = Location.objects.all() 177 178 locations = locations.filter(name__istartswith=token).order_by('name')[:limit] 179 data = [unicode(l) + " (%d items)" % l.items().count() for l in locations] 180 181 return HttpResponse("\n".join(data)) 170 182 171 183 def search(self, request, type = None): 172 184 """Perform a search through collections and items metadata""" 173 collections = MediaCollection.objects. all()174 items = MediaItem.objects. all()185 collections = MediaCollection.objects.enriched() 186 items = MediaItem.objects.enriched() 175 187 input = request.REQUEST 176 188 criteria = {} … … 183 195 collections.word_search('title', value), 184 196 items.by_title(value)), 185 ' country': lambda value: (186 collections.by_ country(value),187 items. filter(etat = value)),197 'location': lambda value: ( 198 collections.by_location(Location.objects.get(name=value)), 199 items.by_location(Location.objects.get(name=value))), 188 200 'continent': lambda value: ( 189 201 collections.by_continent(value), … … 347 359 'country': country, 'continent': country.continents()[0]}) 348 360 349 def get_continents_js(self, request):350 countries = MediaCollection.objects.list_countries()351 return render_to_response('telemeta/geo_continents.js',352 {'countries': countries})353 354 361 def list_countries(self, request, continent): 355 362 continent = Location.objects.by_flatname(continent)[0]
Note: See TracChangeset
for help on using the changeset viewer.
