Permalink
Browse files

fix export formats

  • Loading branch information...
yomguy committed Oct 8, 2012
1 parent 8154647 commit d77a485c593b01b39f4e511bd745c0083ecc4b91
Showing with 15 additions and 16 deletions.
  1. +15 −16 telemeta/views/item.py
View
@@ -47,6 +47,17 @@ class ItemView(object):
cache_data = TelemetaCache(settings.TELEMETA_DATA_CACHE_DIR)
cache_export = TelemetaCache(settings.TELEMETA_EXPORT_CACHE_DIR)
+ export_enabled = getattr(settings, 'TELEMETA_DOWNLOAD_ENABLED', True)
+ export_formats = getattr(settings, 'TELEMETA_DOWNLOAD_FORMATS', ('mp3', 'wav'))
+
+ def get_export_formats(self):
+ formats = []
+ for encoder in self.encoders:
+ if encoder.file_extension() in self.export_formats:
+ formats.append({'name': encoder.format(),
+ 'extension': encoder.file_extension()})
+ return formats
+
def item_previous_next(self, item):
# Get previous and next items
pks = []
@@ -99,15 +110,6 @@ def item_detail(self, request, public_id=None, marker_id=None, width=None, heigh
messages.error(request, title)
return render(request, 'telemeta/messages.html', {'description' : description})
- # Get TimeSide processors
- formats = []
- for encoder in self.encoders:
- if settings.TELEMETA_DOWNLOAD_FORMATS:
- if encoder.file_extension() in settings.TELEMETA_DOWNLOAD_FORMATS:
- formats.append({'name': encoder.format(), 'extension': encoder.file_extension()})
- else:
- formats.append({'name': encoder.format(), 'extension': encoder.file_extension()})
-
graphers = []
for grapher in self.graphers:
graphers.append({'name':grapher.name(), 'id': grapher.id()})
@@ -142,9 +144,9 @@ def item_detail(self, request, public_id=None, marker_id=None, width=None, heigh
format = item.format.get()
return render(request, template,
- {'item': item, 'export_formats': formats,
+ {'item': item, 'export_formats': self.get_export_formats(),
'visualizers': graphers, 'visualizer_id': grapher_id,
- 'audio_export_enabled': getattr(settings, 'TELEMETA_DOWNLOAD_ENABLED', True),
+ 'audio_export_enabled': self.export_enabled,
'previous' : previous, 'next' : next, 'marker': marker_id, 'playlists' : playlists,
'public_access': public_access, 'width': width, 'height': height,
'related_media': related_media, 'mime_type': mime_type, 'last_revision': last_revision,
@@ -167,9 +169,6 @@ def item_edit(self, request, public_id, template='telemeta/mediaitem_edit.html')
except:
grapher_id = 'waveform'
- export_enabled = getattr(settings, 'TELEMETA_DOWNLOAD_ENABLED', True)
- export_formats = getattr(settings, 'TELEMETA_DOWNLOAD_FORMATS', ('mp3', 'wav'))
-
previous, next = self.item_previous_next(item)
mime_type = self.item_analyze(item)
#FIXME: use mimetypes.guess_type
@@ -206,9 +205,9 @@ def item_edit(self, request, public_id, template='telemeta/mediaitem_edit.html')
return render(request, template,
{'item': item,
- 'export_formats': export_formats,
+ 'export_formats': self.get_export_formats(),
'visualizers': graphers, 'visualizer_id': grapher_id,
- 'audio_export_enabled': export_enabled,
+ 'audio_export_enabled': self.export_enabled,
'forms': forms, 'previous' : previous,
'next' : next, 'mime_type': mime_type,
})

0 comments on commit d77a485

Please sign in to comment.