1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-11-17 23:45:11 +00:00

Added additional permission viewer

This commit is contained in:
Ozzieisaacs
2019-05-19 18:39:34 +02:00
parent 0c80f5c63a
commit f70c839014
8 changed files with 49 additions and 8 deletions

View File

@@ -54,6 +54,7 @@ ROLE_PASSWD = 16
ROLE_ANONYMOUS = 32
ROLE_EDIT_SHELFS = 64
ROLE_DELETE_BOOKS = 128
ROLE_VIEWER = 256
DETAIL_RANDOM = 1
@@ -202,6 +203,10 @@ class UserBase:
def role_delete_books(self):
return bool((self.role is not None)and(self.role & ROLE_DELETE_BOOKS == ROLE_DELETE_BOOKS))
def role_viewer(self):
return bool((self.role is not None)and(self.role & ROLE_VIEWER == ROLE_VIEWER))
@property
def is_active(self):
return True
@@ -549,6 +554,12 @@ class Config:
else:
return False
def role_viewer(self):
if self.config_default_role is not None:
return True if self.config_default_role & ROLE_VIEWER == ROLE_VIEWER else False
else:
return False
def role_upload(self):
if self.config_default_role is not None:
return True if self.config_default_role & ROLE_UPLOAD == ROLE_UPLOAD else False
@@ -853,7 +864,8 @@ def create_anonymous_user():
def create_admin_user():
user = User()
user.nickname = "admin"
user.role = ROLE_USER + ROLE_ADMIN + ROLE_DOWNLOAD + ROLE_UPLOAD + ROLE_EDIT + ROLE_DELETE_BOOKS + ROLE_PASSWD
user.role = ROLE_USER + ROLE_ADMIN + ROLE_DOWNLOAD + ROLE_UPLOAD + ROLE_EDIT + ROLE_DELETE_BOOKS + ROLE_PASSWD +\
ROLE_VIEWER
user.sidebar_view = DETAIL_RANDOM + SIDEBAR_LANGUAGE + SIDEBAR_SERIES + SIDEBAR_CATEGORY + SIDEBAR_HOT + \
SIDEBAR_RANDOM + SIDEBAR_AUTHOR + SIDEBAR_BEST_RATED + SIDEBAR_READ_AND_UNREAD + SIDEBAR_RECENT + \
SIDEBAR_SORTED + MATURE_CONTENT + SIDEBAR_PUBLISHER + SIDEBAR_RATING + SIDEBAR_FORMAT