Code cosmetics

This commit is contained in:
OzzieIsaacs 2017-04-02 10:27:37 +02:00
parent 7c6d527a55
commit 7dd70db837
2 changed files with 14 additions and 44 deletions

View File

@ -64,10 +64,7 @@ class UserBase:
return False return False
def role_upload(self): def role_upload(self):
if self.role is not None: return bool((self.role is not None)and(self.role & ROLE_UPLOAD == ROLE_UPLOAD))
return True if self.role & ROLE_UPLOAD == ROLE_UPLOAD else False
else:
return False
def role_edit(self): def role_edit(self):
if self.role is not None: if self.role is not None:
@ -93,11 +90,11 @@ class UserBase:
else: else:
return False return False
@staticmethod @classmethod
def is_active(self): def is_active(self):
return True return True
@staticmethod @classmethod
def is_anonymous(self): def is_anonymous(self):
return False return False
@ -108,58 +105,31 @@ class UserBase:
return self.default_language return self.default_language
def show_random_books(self): def show_random_books(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_RANDOM == SIDEBAR_RANDOM))
return True if self.sidebar_view & SIDEBAR_RANDOM == SIDEBAR_RANDOM else False
else:
return False
def show_language(self): def show_language(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_LANGUAGE == SIDEBAR_LANGUAGE))
return True if self.sidebar_view & SIDEBAR_LANGUAGE == SIDEBAR_LANGUAGE else False
else:
return False
def show_hot_books(self): def show_hot_books(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_HOT == SIDEBAR_HOT))
return True if self.sidebar_view & SIDEBAR_HOT == SIDEBAR_HOT else False
else:
return False
def show_series(self): def show_series(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_SERIES == SIDEBAR_SERIES))
return True if self.sidebar_view & SIDEBAR_SERIES == SIDEBAR_SERIES else False
else:
return False
def show_category(self): def show_category(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_CATEGORY == SIDEBAR_CATEGORY))
return True if self.sidebar_view & SIDEBAR_CATEGORY == SIDEBAR_CATEGORY else False
else:
return False
def show_author(self): def show_author(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_AUTHOR == SIDEBAR_AUTHOR))
return True if self.sidebar_view & SIDEBAR_AUTHOR == SIDEBAR_AUTHOR else False
else:
return False
def show_best_rated_books(self): def show_best_rated_books(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_BEST_RATED == SIDEBAR_BEST_RATED))
return True if self.sidebar_view & SIDEBAR_BEST_RATED == SIDEBAR_BEST_RATED else False
else:
return False
def show_read_and_unread(self): def show_read_and_unread(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & SIDEBAR_READ_AND_UNREAD == SIDEBAR_READ_AND_UNREAD))
return True if self.sidebar_view & SIDEBAR_READ_AND_UNREAD == SIDEBAR_READ_AND_UNREAD else False
else:
return False
def show_detail_random(self): def show_detail_random(self):
if self.sidebar_view is not None: return bool((self.sidebar_view is not None)and(self.sidebar_view & DETAIL_RANDOM == DETAIL_RANDOM))
return True if self.sidebar_view & DETAIL_RANDOM == DETAIL_RANDOM else False
else:
return False
def __repr__(self): def __repr__(self):
return '<User %r>' % self.nickname return '<User %r>' % self.nickname

View File

@ -478,8 +478,8 @@ def fill_indexpage(page, database, db_filter, order):
random = false random = false
off = int(int(config.config_books_per_page) * (page - 1)) off = int(int(config.config_books_per_page) * (page - 1))
pagination = Pagination(page, config.config_books_per_page, pagination = Pagination(page, config.config_books_per_page,
len(db.session.query(database).filter(db_filter).filter(filter).all())) len(db.session.query(database).filter(db_filter).filter(lang_filter).all()))
entries = db.session.query(database).filter(db_filter).filter(filter).order_by(order).offset(off).limit( entries = db.session.query(database).filter(db_filter).filter(lang_filter).order_by(order).offset(off).limit(
config.config_books_per_page) config.config_books_per_page)
return entries, random, pagination return entries, random, pagination