Changeset 20ef7d8


Ignore:
Timestamp:
02/05/2012 15:34:04 (2 years ago)
Author:
yomguy <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:
57305a5, 960da6e
Parents:
04ec884 (diff), c8cdfbe (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@…> (02/05/2012 15:34:04)
git-committer:
yomguy <yomguy@…> (02/05/2012 15:34:04)
Message:

Merge branch 'master' into dev

Files:
7 added
8 edited

Legend:

Unmodified
Added
Removed
  • telemeta/models/__init__.py

    r44cc478 r2444cce  
    4343from dublincore import * 
    4444from language import * 
     45from format import * 
    4546 
  • telemeta/models/enum.py

    r7ed402e rc8cdfbe  
    163163        ordering = ['ethnic_group__value'] 
    164164 
     165 
    165166# Tape formats 
     167class WheelDiameter(Enumeration): 
     168    "Tape wheel diameter (cm)" 
     169 
     170    class Meta(MetaEnumeration): 
     171        db_table = 'tape_wheel_diameter' 
     172        verbose_name = _("tape wheel diameter (cm)") 
     173 
    166174class TapeLength(Enumeration): 
    167175    "Tape length (cm)" 
     
    192200        verbose_name = _("tape vendor") 
    193201 
     202class OriginalFormat(Enumeration): 
     203    "Item original format" 
     204 
     205    class Meta(MetaEnumeration): 
     206        db_table = 'original_format' 
     207        verbose_name = _("original format") 
     208 
  • telemeta/models/media.py

    r742435d r20ef7d8  
    5050from telemeta.models.enum import * 
    5151from telemeta.models.language import * 
     52from telemeta.models.format import * 
    5253from django.db import models 
    5354 
     
    347348    track                 = CharField(_('item number')) 
    348349    creator_reference     = CharField(_('reference')) 
     350    original_format       = ForeignKey(Format, related_name="item", 
     351                                       verbose_name=_('orinal format'), blank=True, 
     352                                        null=True, on_delete=models.SET_NULL) 
    349353    external_references   = TextField(_('published references')) 
    350354    copied_from_item      = WeakForeignKey('self', related_name="copies", verbose_name=_('copy of')) 
     
    694698        verbose_name_plural = _('fonds related media') 
    695699 
    696  
    697 class Format(ModelCore): 
    698     """ Physical format object as proposed by the LAM""" 
    699  
    700     item = ForeignKey(MediaItem, related_name="formats", verbose_name=_('item')) 
    701     original_code = CharField(_('original code'), required=True) 
    702     tape_number = CharField(_('tape number')) 
    703     status = CharField(_('status')) 
    704     conservation_state = CharField(_('conservation state')) 
    705     comments = TextField(_('comments')) 
    706  
    707     tape_length = WeakForeignKey(TapeLength, related_name="formats", verbose_name = _("tape length (cm)")) 
    708     tape_width  = WeakForeignKey(TapeWidth, related_name="formats", verbose_name = _("tape width (inch)")) 
    709     tape_speed = WeakForeignKey(TapeSpeed, related_name="formats", verbose_name = _("tape speed (m/s)")) 
    710     tape_vendor = WeakForeignKey(TapeVendor, related_name="formats") 
    711     tape_thickness = CharField(_('tape thickness (um)')) 
    712     tape_diameter = CharField(_('tape diameter (mm)')) 
    713     tape_reference = CharField(_('tape reference')) 
    714  
    715     class Meta(MetaCore): 
    716         db_table = 'media_formats' 
    717         verbose_name = _('format') 
    718  
    719     def __unicode__(self): 
    720         return self.original_code 
    721  
    722     @property 
    723     def public_id(self): 
    724         return self.original_code 
    725  
  • telemeta/views/base.py

    r742435d r20ef7d8  
    257257        year_min, year_max = MediaCollection.objects.all().publishing_year_range() 
    258258        pub_years = year_min and year_max and range(year_min, year_max + 1) or [] 
    259         searches = Search.objects.filter(username=request.user) 
     259        if request.user.is_authenticated(): 
     260            searches = Search.objects.filter(username=request.user) 
     261        else: 
     262            searches = [] 
    260263        return render(request, 'telemeta/search_criteria.html', { 
    261264            'rec_years': rec_years, 
     
    430433    @method_decorator(login_required) 
    431434    def users(self, request): 
    432         users = User.objects.all() 
     435        users = User.objects.all().order_by('last_name') 
    433436        return render(request, 'telemeta/users.html', {'users': users}) 
    434437 
     
    657660            last_revision = None 
    658661 
    659         physical_format = Format.objects.filter(item=item) 
    660         if physical_format: 
    661             physical_format = physical_format[0] 
     662        physical_format = item.format.physical_format 
    662663 
    663664        return render(request, template, 
  • 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/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 %} 
Note: See TracChangeset for help on using the changeset viewer.