mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
increased comic file name lenght to 100 chars
fixed finding the file extension.
This commit is contained in:
42
comic/migrations/0005_auto_20150625_1400.py
Normal file
42
comic/migrations/0005_auto_20150625_1400.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('comic', '0004_comicbook_unread'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ComicStatus',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('last_read_page', models.IntegerField()),
|
||||||
|
('unread', models.BooleanField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='comicbook',
|
||||||
|
name='last_read_page',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='comicbook',
|
||||||
|
name='unread',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='comicstatus',
|
||||||
|
name='comic',
|
||||||
|
field=models.ForeignKey(to='comic.ComicBook'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='comicstatus',
|
||||||
|
name='user',
|
||||||
|
field=models.ForeignKey(to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
||||||
24
comic/migrations/0006_auto_20150625_1411.py
Normal file
24
comic/migrations/0006_auto_20150625_1411.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('comic', '0005_auto_20150625_1400'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='comicstatus',
|
||||||
|
name='last_read_page',
|
||||||
|
field=models.IntegerField(default=0),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='comicstatus',
|
||||||
|
name='unread',
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
19
comic/migrations/0007_auto_20150626_1820.py
Normal file
19
comic/migrations/0007_auto_20150626_1820.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('comic', '0006_auto_20150625_1411'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='setting',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(unique=True, max_length=100),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -9,7 +9,7 @@ from os import path
|
|||||||
|
|
||||||
|
|
||||||
class Setting(models.Model):
|
class Setting(models.Model):
|
||||||
name = models.CharField(max_length=50, unique=True)
|
name = models.CharField(max_length=100, unique=True)
|
||||||
value = models.TextField()
|
value = models.TextField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@@ -134,13 +134,19 @@ class ComicBook(models.Model):
|
|||||||
book.save()
|
book.save()
|
||||||
i = 0
|
i = 0
|
||||||
for f in sorted([str(x) for x in cbx.namelist()], key=str.lower):
|
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']:
|
if ext in ['jpg', 'jpeg']:
|
||||||
page = ComicPage(Comic=book,
|
page = ComicPage(Comic=book,
|
||||||
index=i,
|
index=i,
|
||||||
page_file_name=f,
|
page_file_name=f,
|
||||||
content_type='image/jpeg')
|
content_type='image/jpeg')
|
||||||
page.save()
|
page.save()
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
elif ext == 'png':
|
elif ext == 'png':
|
||||||
page = ComicPage(Comic=book,
|
page = ComicPage(Comic=book,
|
||||||
|
|||||||
Reference in New Issue
Block a user