fix for issue #2.

This commit is contained in:
2017-11-22 15:56:39 +00:00
parent 28a2f29f5e
commit c330c6812b
5 changed files with 52 additions and 31 deletions

View File

@@ -203,6 +203,8 @@ class ComicBook(models.Model):
book = ComicBook.process_comic_book(next_comic, self.directory)
else:
book = ComicBook.process_comic_book(next_comic)
if type(book) is str:
raise IndexError
comic_path = urlsafe_base64_encode(book.selector.bytes)
cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user)
index = cs.last_read_page
@@ -258,12 +260,16 @@ class ComicBook(models.Model):
comic_full_path = path.join(base_dir, directory.get_path(), comic_file_name)
else:
comic_full_path = path.join(base_dir, comic_file_name)
try:
cbx = rarfile.RarFile(comic_full_path)
except rarfile.NotRarFile:
cbx = None
if not cbx:
try:
cbx = zipfile.ZipFile(comic_full_path)
except zipfile.BadZipfile:
return False
except zipfile.BadZipFile:
return comic_file_name
with atomic():
if directory:
book = ComicBook(file_name=comic_file_name,

View File

@@ -46,18 +46,23 @@ $(document).ready(function() {
"url": "{{ json_url }}",
"data": function ( d ) {
d.csrfmiddlewaretoken = Cookies.get('csrftoken');
},
}
},
"rowCallback": function( row, data, index ) {
var r = $(row);
var cols = $('td:nth-child(n+2)', row);
if (data['selector'] === '0') {
} else {
cols.attr('data-href', data['url']);
cols.attr('style', 'cursor: pointer;')
cols.click(function() {
cols.attr('style', 'cursor: pointer;');
cols.click(function () {
window.document.location = $(this).data("href");
});
}
var tds = $('td:eq(0)', row);
if (data['type'] == 'directory'){
if (data['type'] === 'directory') {
tds.html('');
} else {
tds.html('<input type="checkbox" name="selected" value="'+data['selector']+'" data-type="'+data['type']+'"/>');
@@ -65,25 +70,25 @@ $(document).ready(function() {
cb.change(function() {
$(this).closest('tr').toggleClass('info')
});
};
}
},
"drawCallback": function( settings ) {
var tds = $('table tr td:first-child');
tds.click(function(event){
if (!$(event.target).is('input')) {
var $cb = $('input', this)
var $cb = $('input', this);
$cb.click();
};
}
});
},
"columns": [
{ "data" : "blank", "orderable": false },
{ "data" : "icon", "orderable": false },
{ "data" : "name" },
{ "data" : "label" },
{"data": "label"}
],
"order": [[ 2, 'asc' ]],
"order": [[2, 'asc']]
});
$(".clickable-row").click(function() {
window.document.location = $(this).data("href");
@@ -100,12 +105,12 @@ $(document).ready(function() {
});
$('#select-all').click(function(event){
var cb = $('input', this)
var cb = $('input', this);
if (!$(event.target).is('input')) {
cb.click();
};
}
$('table tr td:first-child input').each(function(chkbx) {
row = $(this)
row = $(this);
if (row.prop('checked') != cb.prop('checked')){
row.click();
}

View File

@@ -98,6 +98,14 @@ class DirFile:
self.type = 'directory'
def populate_comic(self, comic, user):
if type(comic) == str:
self.icon = 'glyphicon-remove'
self.name = comic
self.selector = '0'
self.location = '/'
self.label = '<center><span class="label label-danger">Error</span></center>'
self.type = 'book'
else:
self.icon = 'glyphicon-book'
self.name = comic.file_name
status, created = ComicStatus.objects.get_or_create(comic=comic, user=user)

View File

@@ -1,5 +1,6 @@
from captcha.fields import CaptchaField
from django import forms
from captcha.fields import ReCaptchaField
from comic.models import Setting
@@ -33,7 +34,7 @@ class LoginForm(forms.Form):
public_key = Setting.objects.get(name='RECAPTCHA_PUBLIC_KEY').value
private_key = Setting.objects.get(name='RECAPTCHA_PRIVATE_KEY').value
captcha = ReCaptchaField(
captcha = CaptchaField(
label='',
public_key=public_key,
private_key=private_key,

View File

@@ -1,2 +1,3 @@
ujson
django
django-simple-captcha