Permalink
Browse files

Fixes to the formats property - keys are now extensions without the l…

…eading '.' for easier use in a template, like {{instance.video.formats.flv}}
  • Loading branch information...
1 parent 9ae0315 commit 35d3b536cb527be9eb900883abd1071001dac336 @nmfm committed Oct 25, 2011
Showing with 8 additions and 4 deletions.
  1. +5 −4 filer/fields/multistorage_file.py
  2. +3 −0 filer/models/videomodels.py
@@ -1,4 +1,5 @@
#-*- coding: utf-8 -*-
+import os
from django.core.files.base import File
from django.core.files.storage import Storage
from easy_thumbnails import fields as easy_thumbnails_fields, \
@@ -36,14 +37,14 @@ class FormatNameMixin(object):
def get_format_name(self, ext):
path, source_filename = os.path.split(self.name)
filename, extension = os.path.splitext(source_filename)
- if format_ext.starts_with('.'):
- newfilename = '%s%s' % (filename, format_ext)
+ if ext.startswith('.'):
+ newfilename = '%s%s' % (filename, ext)
else:
- newfilename = '%s.%s' % (filename, format_ext)
+ newfilename = '%s.%s' % (filename, ext)
return os.path.join(path, newfilename)
def get_format_url(self, ext):
- base_name = self.get_format_name(format_ext)
+ base_name = self.get_format_name(ext)
if self.format_storage.exists(base_name):
return os.path.join(self.format_storage.base_url, base_name)
else:
@@ -60,7 +60,10 @@ def _check_validity(self):
@property
def formats(self):
_formats = {}
+ import pdb; pdb.set_trace()
for ext in filer_settings.FILER_VIDEO_FORMATS:
+ if ext.startswith('.'):
+ ext = ext[1:]
try:
_formats[ext] = self.file.get_format_url(ext)
except Exception, e:

0 comments on commit 35d3b53

Please sign in to comment.