]> git.parisson.com Git - telemeta.git/commitdiff
fix access rights to items
authoryomguy <yomguy@parisson.com>
Fri, 25 Mar 2011 15:45:57 +0000 (16:45 +0100)
committeryomguy <yomguy@parisson.com>
Fri, 25 Mar 2011 15:45:57 +0000 (16:45 +0100)
telemeta/templates/telemeta_default/mediaitem_detail.html
telemeta/web/base.py

index 56f2b3fb0873e134318567b8e13cd0c23101d907..5d3616c7b87bed9643cb9b3a145d06c06c278567 100644 (file)
@@ -66,7 +66,7 @@
 
 <div class="{% if item.file %}{% if item.public_access == 'full' or public_access or user.is_staff %}with-rightcol{% endif %}{% endif %}">
    {% if item.file %}
-    {% if item.public_access == 'full' or public_access or user.is_staff %}
+    {% if public_access or user.is_staff %}
     <div id="player_maximized" class="ts-skin-lab">
         <a href="#" class="toggle">Minimize</a>
         <div class="wazing"></div>
index fbe392cc96d8957ad6da7543da7358e5ef72a1a3..893076f141d650888050dd36e70035dbcfafa260 100644 (file)
@@ -196,6 +196,7 @@ class WebView(object):
                 if not code:
                     code = public_id
                 form.save()
+                new_collection.set_revision(request.user)
                 return HttpResponseRedirect('/collections/'+code)
         else:
             form = MediaCollectionForm(instance=collection)
@@ -362,7 +363,7 @@ class WebView(object):
                 if not code:
                     code = public_id
                 form.save()
-                item.set_revision(request.user)
+                new_item.set_revision(request.user)
                 return HttpResponseRedirect('/items/'+code)
         else:
             form = MediaItemForm(instance=item)
@@ -456,9 +457,10 @@ class WebView(object):
         """Export a given media item in the specified format (OGG, FLAC, ...)"""
         
         item = MediaItem.objects.get(public_id=public_id)
-        
-        if settings.TELEMETA_DOWNLOAD_ENABLED == False or not item.public_access == 'full':
-            return HttpResponseRedirect('/not_allowed/')
+
+        public_access = self.get_public_access(item.public_access, item.recorded_from_date, item.recorded_to_date)
+        if (not public_access or not settings.TELEMETA_DOWNLOAD_ENABLED) and not request.user.is_staff:
+            return HttpResponseRedirect('not_allowed/')
 
         for encoder in self.encoders:
             if encoder.file_extension() == extension:
@@ -470,11 +472,18 @@ class WebView(object):
         mime_type = encoder.mime_type()
         file = public_id + '.' + encoder.file_extension()
         audio = item.file.path
-        __decoder = timeside.decoder.FileDecoder(audio)
-        format = __decoder.format()
+        
+        analyzers = self.item_analyze(item)
+        if analyzers:
+            for analyzer in analyzers:
+                if analyzer['id'] == 'mime_type':
+                    format = analyzer['value']
+        else:
+            __decoder = timeside.decoder.FileDecoder(audio)
+            format = __decoder.format()
+        
         if format == mime_type:
             # source > stream
-            __decoder.release()
             response = HttpResponse(stream_from_file(audio), mimetype = mime_type)
             
         else:        
@@ -486,7 +495,7 @@ class WebView(object):
                 __proc.setup(channels=__decoder.channels(), samplerate=__decoder.samplerate(), nframes=__decoder.nframes())
 #                metadata = dublincore.express_item(item).to_list()
 #                enc.set_metadata(metadata)
-                response = HttpResponse(stream_from___processor(__decoder, __proc), mimetype = mime_type)
+                response = HttpResponse(stream_from_processor(__decoder, __proc), mimetype = mime_type)
             else:
                 # cache > stream
                 response = HttpResponse(self.cache_export.read_stream_bin(file), mimetype = mime_type)