fixed custom columns handling on dispose

This commit is contained in:
Daniel Pavel 2019-07-17 11:42:19 +03:00
parent 99c6247baf
commit 847dbfc021
6 changed files with 3 additions and 10 deletions

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
@ -134,8 +133,7 @@ def get_locale():
@babel.timezoneselector @babel.timezoneselector
def get_timezone(): def get_timezone():
user = getattr(g, 'user', None) user = getattr(g, 'user', None)
if user is not None: return user.timezone if user else None
return user.timezone
from .updater import Updater from .updater import Updater
updater_thread = Updater() updater_thread = Updater()

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
@ -418,7 +417,7 @@ def dispose():
for attr in list(Books.__dict__.keys()): for attr in list(Books.__dict__.keys()):
if attr.startswith("custom_column_"): if attr.startswith("custom_column_"):
delattr(Books, attr) setattr(Books, attr, None)
for db_class in cc_classes.values(): for db_class in cc_classes.values():
Base.metadata.remove(db_class.__table__) Base.metadata.remove(db_class.__table__)

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
@ -301,7 +300,7 @@ def edit_cc_data(book_id, book, to_save):
# remove old cc_val # remove old cc_val
del_cc = getattr(book, cc_string)[0] del_cc = getattr(book, cc_string)[0]
getattr(book, cc_string).remove(del_cc) getattr(book, cc_string).remove(del_cc)
if len(del_cc.books) == 0: if not del_cc.books or len(del_cc.books) == 0:
db.session.delete(del_cc) db.session.delete(del_cc)
else: else:
input_tags = to_save[cc_string].split(',') input_tags = to_save[cc_string].split(',')

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)

View File

@ -1,4 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)