Changeset 3b631ab
- Timestamp:
- 04/03/12 12:47:16 (14 months ago)
- Branches:
- master, crem, crem2, dev, diadems, generic, instru_search, lam, nlivemulti, release/1.4.4, security, social, storage, test
- Children:
- 6a6127e
- Parents:
- e142272 (diff), d36c84a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- yomguy <yomguy@…> (04/03/12 12:47:16)
- git-committer:
- yomguy <yomguy@…> (04/03/12 12:47:16)
- Location:
- telemeta
- Files:
-
- 6 edited
-
templates/telemeta/base.html (modified) (1 diff)
-
models/media.py (modified) (1 diff)
-
models/query.py (modified) (5 diffs)
-
templates/telemeta/search_criteria.html (modified) (1 diff)
-
templates/telemeta/search_results.html (modified) (1 diff)
-
views/base.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
telemeta/templates/telemeta/base.html
r8a5b1b5 rd36c84a 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">1 <!DOCTYPE html> 2 2 {% load i18n %} 3 3 {% load telemeta_utils %} -
telemeta/models/media.py
rfabced9 rbf87cda 408 408 title += ' ' + self.track 409 409 return title 410 411 @property 412 def instruments(self): 413 "Return the instruments of the item" 414 instruments = [] 415 performances = MediaItemPerformance.objects.filter(media_item=self) 416 for performance in performances: 417 instrument = performance.instrument 418 alias = performance.alias 419 if not instrument in instruments: 420 instruments.append(instrument) 421 if not alias in instruments: 422 instruments.append(alias) 423 424 instruments.sort(self.__name_cmp) 425 return instruments 426 427 instruments.verbose_name = _("instruments") 410 428 411 429 -
telemeta/models/query.py
r2f57f0e rc9f9871 201 201 return self.filter(file__contains='/') 202 202 203 def by_instrument(self, instrument): 204 "Find items by instrument" 205 return self.filter(instruments__in=instrument) 206 203 207 204 208 class MediaItemManager(CoreManager): … … 244 248 return self.get_query_set().sound(*args, **kwargs) 245 249 sound.__doc__ = MediaItemQuerySet.sound.__doc__ 250 251 def by_instrument(self, *args, **kwargs): 252 return self.get_query_set().by_instrument(*args, **kwargs) 253 by_instrument.__doc__ = MediaItemQuerySet.by_instrument.__doc__ 246 254 247 255 … … 332 340 return self.filter(items__file__contains='/').distinct() 333 341 342 def by_instrument(self, instrument): 343 "Find collections by instrument" 344 return self.filter(items__instruments__in=instrument).distinct() 345 334 346 335 347 class MediaCollectionManager(CoreManager): … … 375 387 return self.get_query_set().sound(*args, **kwargs) 376 388 sound.__doc__ = MediaCollectionQuerySet.sound.__doc__ 389 390 def by_instrument(self, *args, **kwargs): 391 return self.get_query_set().by_instrument(*args, **kwargs) 392 by_instrument.__doc__ = MediaCollectionQuerySet.by_instrument.__doc__ 377 393 378 394 … … 478 494 return self.get_query_set().quick_search(*args, **kwargs) 479 495 quick_search.__doc__ = MediaFondsQuerySet.quick_search.__doc__ 496 497 498 class InstrumentQuerySet(CoreQuerySet): 499 "Base class for all media instrument query sets" 500 501 def quick_search(self, pattern): 502 "Perform a quick search on text and char fields" 503 from telemeta.models.instrument import Instrument 504 mod = Instrument() 505 pattern = pattern.strip() 506 q = Q(code__contains=pattern) 507 fields = mod.to_dict() 508 keys = fields.keys() 509 for field in keys: 510 field_str = str(mod._meta.get_field(field)) 511 if 'CharField' in field_str or 'TextField' in field_str: 512 q = q | word_search_q(field, pattern) 513 return self.filter(q) 514 515 516 class InstrumentManager(CoreManager): 517 "Manage instrument queries" 518 519 def get_query_set(self): 520 "Return instrument query sets" 521 return InstrumentQuerySet(self.model) 522 523 def quick_search(self, *args, **kwargs): 524 return self.get_query_set().quick_search(*args, **kwargs) 525 quick_search.__doc__ = InstrumentQuerySet.quick_search.__doc__ -
telemeta/templates/telemeta/search_criteria.html
r566f17d rc9f9871 63 63 <label for="location">{% field_label "Location" %}</label> 64 64 <input type="text" name="location" id="location" value="{{ criteria.location }}" /> 65 </p> 66 67 <p> 68 <label for="instrument">{% field_label "Instrument" %}</label> 69 <input type="text" name="instrument" id="instrument" /> 65 70 </p> 66 71 -
telemeta/templates/telemeta/search_results.html
r7baa3c8 rc9f9871 28 28 {% if criteria.location %} 29 29 <li><b>{% field_label "Location" %}:</b> {{criteria.location}}</li> 30 {% endif %} 31 {% if criteria.instrument %} 32 <li><b>{% field_label "Instrument" %}:</b> {{criteria.instrument}}</li> 30 33 {% endif %} 31 34 {% if criteria.ethnic_group %} -
telemeta/views/base.py
ref72a4d r18b4f7b 339 339 collections.sound(), 340 340 items.sound()), 341 'instrument': lambda value: ( 342 collections.by_instrument(value), 343 items.by_instrument(value)), 341 344 } 342 345
Note: See TracChangeset
for help on using the changeset viewer.
