Changeset b329804


Ignore:
Timestamp:
May 2, 2012 4:07:35 PM (2 years ago)
Author:
Guillaume Pellerin <yomguy@…>
Branches:
master, crem, crem2, dev, dev2, diadems, 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:
d68b189, 03ca023
Parents:
7a49503 (diff), cd6363d (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:
Guillaume Pellerin <yomguy@…> (02/05/2012 16:07:35)
git-committer:
Guillaume Pellerin <yomguy@…> (02/05/2012 16:07:35)
Message:

Merge branch 'master' of /var/git/telemeta

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tools/dev/push.sh

    r28fa06b rcd6363d  
    2222#echo "Update jimi.parisson.com:" 
    2323echo "Update angus.parisson.com:" 
    24 ssh angus.parisson.com "cd /home/telemeta/telemeta-prod; git pull origin production; \ 
    25                         cd /home/telemeta/telemeta; git pull origin master; \ 
     24ssh angus.parisson.com "cd /home/telemeta/telemeta-master; git pull origin master; \ 
     25                        cd /home/telemeta/telemeta-develop; git pull origin develop; \ 
    2626                        cd /home/telemeta/demo/; ./manage.py migrate telemeta --delete-ghost-migrations; 
    2727                        cd /home/telemeta/sandbox/; ./manage.py migrate telemeta --delete-ghost-migrations;  
  • README.rst

    r0d62fe4 r04ec884  
    191191  * MMSH : Maison Méditerranéenne des Sciences de l'Homme 
    192192    http://www.mmsh.univ-aix.fr/ 
     193 
  • telemeta/models/media.py

    r2444cce r20ef7d8  
    412412            title += ' ' + self.track 
    413413        return title 
     414 
     415    @property 
     416    def instruments(self): 
     417        "Return the instruments of the item" 
     418        instruments = [] 
     419        performances = MediaItemPerformance.objects.filter(media_item=self) 
     420        for performance in performances: 
     421            instrument = performance.instrument 
     422            alias = performance.alias 
     423            if not instrument in instruments: 
     424                instruments.append(instrument) 
     425            if not alias in instruments: 
     426                instruments.append(alias) 
     427 
     428        instruments.sort(self.__name_cmp) 
     429        return instruments 
     430 
     431        instruments.verbose_name = _("instruments") 
    414432 
    415433 
  • 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

    r2444cce r42d8c45  
    344344                collections.sound(), 
    345345                items.sound()), 
     346            'instrument': lambda value: ( 
     347                collections.by_instrument(value), 
     348                items.by_instrument(value)), 
    346349        } 
    347350 
     
    14771480    subjects = settings.TELEMETA_SUBJECTS 
    14781481    tags = ['title', 'description', 'comment'] 
    1479     title = organization + ' - Telemeta - ' + ugettext('Last changes') 
     1482    title = organization.decode('utf8') + ' - Telemeta - ' + ugettext('Last changes') 
    14801483    link = "" 
    14811484    description = ' '.join([subject.decode('utf-8') for subject in subjects]) 
Note: See TracChangeset for help on using the changeset viewer.