Changeset 86f7310


Ignore:
Timestamp:
Mar 5, 2012 1:17:31 PM (3 years ago)
Author:
yomguy <yomguy@…>
Branches:
master, crem, crem2, dev, dev2, diadems, dj1.6, feature/breadcrumbs, feature/ts-0.5, feature/ts-0.5.4, feature/writecache, generic, instru_search, lam, lam2, mapsv3, merge, nlivemulti, release/1.4.4, sabiod, security, server, social, storage, telecaster, test
Children:
bf87cda
Parents:
3c13a83 (diff), dd763818 (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@…> (05/03/2012 13:17:31)
git-committer:
yomguy <yomguy@…> (05/03/2012 13:17:31)
Message:

Merge branch 'master' into dev

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • README.rst

    r90b13fd rdd763818  
    44 
    55For personal or collaborative media archiving projects, 
    6 research laboratories and digital humanities, 
     6research laboratories and digital humanities. 
    77 
    8 based on Django, Python, full DHTML, CSS and JavaScript. 
     8Based on Django, Python, full DHTML, CSS and JavaScript. 
    99 
    1010 
     
    1414Telemeta is a free and open source web audio archiving software which introduces useful and secure methods to backup, index, transcode, analyse and publish any digitalized audio file with its metadata. It is dedicated to professionnals who wants to easily organize, backup and publish documented sound collections of audio files, CDs, digitalized vinyls and magnetic tapes over a strong database, in accordance with open web standards. 
    1515 
    16 Here are the main features of Telemeta: 
     16Main features: 
    1717 
    1818 * Secure archiving, editing and publishing of audio files over internet. 
  • telemeta/models/media.py

    rea5ec32 rc9f9871  
    408408            title += ' ' + self.track 
    409409        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") 
    410428 
    411429 
  • telemeta/models/query.py

    r2f57f0e rc9f9871  
    201201        return self.filter(file__contains='/') 
    202202 
     203    def by_instrument(self, instrument): 
     204        "Find items by instrument" 
     205        return self.filter(instruments__in=instrument) 
     206 
    203207 
    204208class MediaItemManager(CoreManager): 
     
    244248        return self.get_query_set().sound(*args, **kwargs) 
    245249    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__ 
    246254 
    247255 
     
    332340        return self.filter(items__file__contains='/').distinct() 
    333341 
     342    def by_instrument(self, instrument): 
     343        "Find collections by instrument" 
     344        return self.filter(items__instruments__in=instrument).distinct() 
     345 
    334346 
    335347class MediaCollectionManager(CoreManager): 
     
    375387        return self.get_query_set().sound(*args, **kwargs) 
    376388    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__ 
    377393 
    378394 
     
    478494        return self.get_query_set().quick_search(*args, **kwargs) 
    479495    quick_search.__doc__ = MediaFondsQuerySet.quick_search.__doc__ 
     496 
     497 
     498class 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 
     516class 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  
    6363    <label for="location">{% field_label "Location" %}</label> 
    6464    <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" /> 
    6570    </p> 
    6671 
  • telemeta/templates/telemeta/search_results.html

    r7baa3c8 rc9f9871  
    2828  {% if criteria.location %} 
    2929    <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> 
    3033  {% endif %} 
    3134  {% if criteria.ethnic_group %} 
  • telemeta/views/base.py

    r0d2f73e r3c13a83  
    339339                collections.sound(), 
    340340                items.sound()), 
     341            'instrument': lambda value: ( 
     342                collections.by_instrument(value), 
     343                items.by_instrument(value)), 
    341344        } 
    342345 
Note: See TracChangeset for help on using the changeset viewer.