Changeset 77469e8
- Timestamp:
- 04/23/07 15:37:06 (6 years ago)
- Branches:
- master, crem, crem2, dev, dev2, diadems, forma, generic, instru_search, lam, nlivemulti, production, release/1.4.4, security, social, storage, test, video
- Children:
- 9ccc928
- Parents:
- e789173
- git-author:
- olivier <> (04/23/07 15:37:06)
- git-committer:
- olivier <> (04/23/07 15:37:06)
- Location:
- telemeta
- Files:
-
- 1 added
- 6 edited
-
css/style.css (modified) (3 diffs)
-
models.py (modified) (5 diffs)
-
templates/base.html (modified) (1 diff)
-
templates/index.html (modified) (1 diff)
-
templates/search_results.html (added)
-
urls.py (modified) (1 diff)
-
views/web.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telemeta/css/style.css
r6d9a741 r77469e8 1 1 body { 2 2 font-family: Verdana; 3 font-size: 11px;3 font-size: 80%; 4 4 } 5 5 6 6 #header { 7 font-size: 1 6px;7 font-size: 140%; 8 8 border-bottom: solid 1px black; 9 9 font-weight: bold; 10 padding-bottom: 0.8em; 11 padding-top: 1em; 12 } 13 #header a { 14 color: black; 15 text-decoration: none; 10 16 } 11 17 18 /* 12 19 label { 13 20 width: 20ex; … … 15 22 float: left; 16 23 } 17 18 24 input { 19 margin-bottom: 4px;25 margin-bottom: 1ex; 20 26 } 27 */ 21 28 22 29 #menu { 23 30 text-align: right; 31 clear: right; 24 32 } 25 33 … … 37 45 #menu a { 38 46 } 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 1 1 import telemeta 2 2 from django.db import models 3 from django.db.models import Q 3 4 from telemeta.core import * 4 5 … … 19 20 return fields_dict 20 21 22 class 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 21 29 class MediaCollection(models.Model, MediaCore): 22 30 "Group related media items" … … 36 44 subject = models.CharField(maxlength=250, blank=True) 37 45 46 objects = MediaCollectionManager() 47 38 48 def __str__(self): 39 49 return self.title … … 46 56 pass 47 57 48 58 class 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 ) 49 66 50 67 class MediaItem(models.Model, MediaCore): … … 68 85 source = models.CharField(maxlength=250, blank=True) 69 86 duration = models.FloatField(max_digits=11, decimal_places=3, null=True, blank=True) 87 88 objects = MediaItemManager() 70 89 71 90 def __str__(self): -
telemeta/templates/base.html
r6d9a741 r77469e8 3 3 <body> 4 4 <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> 6 13 </div> 7 14 <div id="menu"> 8 15 <a href="/collections">Collections</a> | 9 <a href="/items">Items</a> 16 <a href="/items">Items</a> | 17 <a href="/admin">Admin</a> 10 18 </div> 11 19 {% block content %}{% endblock %} -
telemeta/templates/index.html
r6d9a741 r77469e8 2 2 3 3 {% 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 %}17 4 {% endblock %} -
telemeta/urls.py
r6d9a741 r77469e8 26 26 dict(all_collections, template_name="collection_detail.html")), 27 27 28 (r'^search/$', 29 'telemeta.views.web.quick_search'), 30 28 31 29 32 # CSS (FIXME: for developement only) -
telemeta/views/web.py
r6d9a741 r77469e8 5 5 from django.http import Http404 6 6 from telemeta.models import MediaItem 7 from telemeta.models import MediaCollection 7 8 from django.shortcuts import render_to_response 8 9 import re … … 68 69 outfile = exporter.process(item.id, infile, metadata, []) 69 70 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 71 85 72 86 comp_mgr = ComponentManager() … … 74 88 item_detail = view.item_detail 75 89 item_export = view.item_export 90 quick_search = view.quick_search 76 91 77 92 def media_item_edit(request, media_item_id):
Note: See TracChangeset
for help on using the changeset viewer.
