Changeset 77469e8


Ignore:
Timestamp:
Apr 23, 2007 3:37:06 PM (8 years ago)
Author:
olivier <>
Branches:
master, crem, crem2, crem3, 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, search, 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

Location:
telemeta
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • telemeta/css/style.css

    r6d9a741 r77469e8  
    11body { 
    22    font-family: Verdana; 
    3     font-size: 11px; 
     3    font-size: 80%; 
    44} 
    55 
    66#header { 
    7     font-size: 16px; 
     7    font-size: 140%; 
    88    border-bottom: solid 1px black; 
    99    font-weight: bold; 
     10    padding-bottom: 0.8em; 
     11    padding-top: 1em; 
     12} 
     13#header a { 
     14    color: black; 
     15    text-decoration: none; 
    1016} 
    1117 
     18/* 
    1219label { 
    1320    width: 20ex; 
     
    1522    float: left; 
    1623} 
    17  
    1824input { 
    19     margin-bottom: 4px; 
     25    margin-bottom: 1ex; 
    2026} 
     27*/ 
    2128 
    2229#menu { 
    2330    text-align: right; 
     31    clear: right; 
    2432} 
    2533 
     
    3745#menu a { 
    3846} 
     47 
     48#quick_search { 
     49    float: right; 
     50    font-size: 80%; 
     51} 
     52 
     53#quick_search input { 
     54    vertical-align: middle; 
     55    font-size: 80%; 
     56} 
     57 
     58#quick_search_pattern { 
     59} 
  • 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): 
  • telemeta/templates/base.html

    r6d9a741 r77469e8  
    33<body> 
    44<div id="header"> 
    5 Telemeta Web Interface 
     5<a href="/">Telemeta Web Interface</a> 
     6    <div id="quick_search"> 
     7    <form action="/search" method="GET"> 
     8    <label for="quick_search_pattern">Search : </label> 
     9        <input id="quick_search_pattern" name="pattern" /> 
     10        <input type="submit" value="OK" /> 
     11    </form>         
     12    </div> 
    613</div> 
    714<div id="menu"> 
    815<a href="/collections">Collections</a> | 
    9 <a href="/items">Items</a> 
     16<a href="/items">Items</a> | 
     17<a href="/admin">Admin</a> 
    1018</div> 
    1119{% block content %}{% endblock %} 
  • telemeta/templates/index.html

    r6d9a741 r77469e8  
    22 
    33{% block content %} 
    4 <h3>Media items</h3> 
    5 {% if object_list %} 
    6     <ul> 
    7     {% for p in object_list %} 
    8         <li><b>{{ p.author }}</b> - {{ p.title }} 
    9             <a href="{{ p.id }}">View</a> 
    10             <a href="#">Edit</a> 
    11             </li> 
    12     {% endfor %} 
    13     </ul> 
    14 {% else %} 
    15     <p>No media item available.</p> 
    16 {% endif %} 
    174{% endblock %} 
  • telemeta/urls.py

    r6d9a741 r77469e8  
    2626        dict(all_collections, template_name="collection_detail.html")), 
    2727 
     28    (r'^search/$',  
     29        'telemeta.views.web.quick_search'), 
     30 
    2831 
    2932    # CSS (FIXME: for developement only) 
  • telemeta/views/web.py

    r6d9a741 r77469e8  
    55from django.http import Http404 
    66from telemeta.models import MediaItem 
     7from telemeta.models import MediaCollection 
    78from django.shortcuts import render_to_response 
    89import re 
     
    6869        outfile = exporter.process(item.id, infile, metadata, []) 
    6970 
    70         return HttpResponse(self.file_stream(outfile), mimetype = mime_type) 
     71        response = HttpResponse(self.file_stream(outfile), mimetype = mime_type) 
     72        response['Content-Disposition'] = 'attachment; filename="download.' + \ 
     73                    exporter.get_file_extension() + '"' 
     74        return response 
     75 
     76    def quick_search(self, request): 
     77        pattern = request.REQUEST["pattern"] 
     78        collections = MediaCollection.objects.quick_search(pattern) 
     79        items = MediaItem.objects.quick_search(pattern) 
     80        return render_to_response('search_results.html',  
     81                    {'pattern': pattern, 'collections': collections,  
     82                     'items': items}) 
     83 
     84         
    7185 
    7286comp_mgr = ComponentManager() 
     
    7488item_detail = view.item_detail 
    7589item_export = view.item_export 
     90quick_search = view.quick_search 
    7691 
    7792def media_item_edit(request, media_item_id): 
Note: See TracChangeset for help on using the changeset viewer.