Changeset 77469e8 for telemeta/models.py


Ignore:
Timestamp:
Apr 23, 2007 3:37:06 PM (8 years ago)
Author:
olivier <>
Branches:
master, crem, crem2, dev, dev2, diadems, dj1.6, feature/breadcrumbs, feature/ts-0.5, feature/ts-0.5.4, feature/writecache, forma, generic, instru_search, lam, lam2, mapsv3, merge, nlivemulti, production, release/1.4.4, sabiod, security, server, social, storage, telecaster, test, video
Children:
9ccc928
Parents:
e789173
git-author:
olivier <> (23/04/2007 15:37:06)
git-committer:
olivier <> (23/04/2007 15:37:06)
Message:

web interface: added quick search and fixed export download

File:
1 edited

Legend:

Unmodified
Added
Removed
  • telemeta/models.py

    r6d9a741 r77469e8  
    11import telemeta 
    22from django.db import models 
     3from django.db.models import Q 
    34from telemeta.core import * 
    45 
     
    1920        return fields_dict 
    2021 
     22class MediaCollectionManager(models.Manager): 
     23    def quick_search(self, pattern): 
     24        return super(MediaCollectionManager, self).get_query_set().filter( 
     25            Q(title__icontains=pattern) | 
     26            Q(description__icontains=pattern) 
     27        ) 
     28 
    2129class MediaCollection(models.Model, MediaCore): 
    2230    "Group related media items" 
     
    3644    subject = models.CharField(maxlength=250, blank=True) 
    3745 
     46    objects = MediaCollectionManager() 
     47 
    3848    def __str__(self): 
    3949        return self.title 
     
    4656        pass 
    4757 
    48  
     58class MediaItemManager(models.Manager): 
     59    def quick_search(self, pattern): 
     60        return super(MediaItemManager, self).get_query_set().filter( 
     61            Q(title__icontains=pattern) | 
     62            Q(creator__icontains=pattern) | 
     63            Q(identifier__icontains=pattern) | 
     64            Q(description__icontains=pattern)  
     65        ) 
    4966 
    5067class MediaItem(models.Model, MediaCore): 
     
    6885    source = models.CharField(maxlength=250, blank=True) 
    6986    duration = models.FloatField(max_digits=11, decimal_places=3, null=True, blank=True) 
     87 
     88    objects = MediaItemManager() 
    7089 
    7190    def __str__(self): 
Note: See TracChangeset for help on using the changeset viewer.