diff --git a/cps/__init__.py b/cps/__init__.py index 26750d1a018ad0f9e4c442470beca785f2b71928..d26c3cdc649d54b07432825fc6cbd352e66f851f 100755 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) @@ -134,8 +133,7 @@ def get_locale(): @babel.timezoneselector def get_timezone(): user = getattr(g, 'user', None) - if user is not None: - return user.timezone + return user.timezone if user else None from .updater import Updater updater_thread = Updater() diff --git a/cps/constants.py b/cps/constants.py index 2bedb2822d2068587b906e6debc8427eda8eeed2..9d4938b22527ea997a2407efa9d642a66c783f91 100644 --- a/cps/constants.py +++ b/cps/constants.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) diff --git a/cps/db.py b/cps/db.py index 1ed56234b3513ea4ad411b6ffde3acde023624fb..b9853896a54c29a2aa87b8875ff8c9b904f8c6c3 100755 --- a/cps/db.py +++ b/cps/db.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # 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()): if attr.startswith("custom_column_"): - delattr(Books, attr) + setattr(Books, attr, None) for db_class in cc_classes.values(): Base.metadata.remove(db_class.__table__) diff --git a/cps/editbooks.py b/cps/editbooks.py index 8851a0d89dde77db85e9271613ca37c60746393b..2da9991f14f90dcdae3931bbce1456c2f4d8acae 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # 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 del_cc = getattr(book, cc_string)[0] 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) else: input_tags = to_save[cc_string].split(',') diff --git a/cps/helper.py b/cps/helper.py index d7308d04625b2346d232b573921569c4dfb2d996..c94093dbb898ea521cb9653b8d5d0337b33a02a8 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web) diff --git a/cps/worker.py b/cps/worker.py index 37212873fb2bf0dac3d0bca36a903d79bb1dae4c..9744b91f9177acd5ff23e7bb3255806461071b76 100644 --- a/cps/worker.py +++ b/cps/worker.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)