increased comic file name lenght to 100 chars

fixed finding the file extension.
This commit is contained in:
2015-06-26 18:33:10 +01:00
parent 15d00c3f94
commit fa4fdff0e6
4 changed files with 93 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ from os import path
class Setting(models.Model):
name = models.CharField(max_length=50, unique=True)
name = models.CharField(max_length=100, unique=True)
value = models.TextField()
def __str__(self):
@@ -134,13 +134,19 @@ class ComicBook(models.Model):
book.save()
i = 0
for f in sorted([str(x) for x in cbx.namelist()], key=str.lower):
ext = f.lower()[-3:]
try:
dot_index = f.rindex('.') + 1
except ValueError:
continue
ext = f.lower()[dot_index:]
print ext
if ext in ['jpg', 'jpeg']:
page = ComicPage(Comic=book,
index=i,
page_file_name=f,
content_type='image/jpeg')
page.save()
i += 1
elif ext == 'png':
page = ComicPage(Comic=book,