file names and upload file size

This commit is contained in:
j 2011-04-12 21:22:03 +02:00
parent fca156f5c7
commit fbf7196d7a
2 changed files with 11 additions and 5 deletions

View file

@ -303,7 +303,11 @@ class File(models.Model):
return None
def get_folder(self):
instance = self.get_instance()
if instance:
return instance.folder
name = os.path.splitext(self.get_name())[0]
name = name.replace('. ', '||').split('.')[0].replace('||', '. ')
if self.item:
if settings.USE_IMDB:
director = self.item.get('director', ['Unknown Director'])
@ -321,16 +325,13 @@ class File(models.Model):
def get_name(self):
instance = self.get_instance()
if instance:
return self.get_instance().name
return instance.name
if self.item:
name = self.item.get('title', 'Untitled')
name = re.sub(r'[:\\/]', '_', name)
if not name:
name = 'Untitled'
if self.instances.count() > 0:
ext = os.path.splitext(self.instances.all()[0].name)[-1]
else:
ext = '.unknown'
ext = '.unknown'
return name + ext
class Volume(models.Model):

View file

@ -87,6 +87,11 @@ STATIC_URL = '/static/'
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/admin/media/'
#max upload size,
#needs to be in line with setting in nginx/apache
FILE_UPLOAD_MAX_MEMORY_SIZE=32*1024*1024
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',