diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html
index 2dac08f6..fa36955a 100644
--- a/cps/templates/config_edit.html
+++ b/cps/templates/config_edit.html
@@ -49,6 +49,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{% if not origin %}
{{_('Back')}}
diff --git a/cps/ub.py b/cps/ub.py
index 3e86c994..1da77f83 100644
--- a/cps/ub.py
+++ b/cps/ub.py
@@ -262,6 +262,7 @@ class Settings(Base):
config_uploading = Column(SmallInteger, default=0)
config_anonbrowse = Column(SmallInteger, default=0)
config_public_reg = Column(SmallInteger, default=0)
+ config_default_role = Column(SmallInteger, default=0)
def __repr__(self):
pass
@@ -287,6 +288,7 @@ class Config:
self.config_uploading = data.config_uploading
self.config_anonbrowse = data.config_anonbrowse
self.config_public_reg = data.config_public_reg
+ self.config_default_role = data.config_default_role
if self.config_calibre_dir is not None: # and (self.db_configured is None or self.db_configured is True):
self.db_configured = True
else:
@@ -296,6 +298,36 @@ class Config:
def get_main_dir(self):
return self.config_main_dir
+ def role_admin(self):
+ if self.config_default_role is not None:
+ return True if self.config_default_role & ROLE_ADMIN == ROLE_ADMIN else False
+ else:
+ return False
+
+ def role_download(self):
+ if self.config_default_role is not None:
+ return True if self.config_default_role & ROLE_DOWNLOAD == ROLE_DOWNLOAD 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
+ else:
+ return False
+
+ def role_edit(self):
+ if self.config_default_role is not None:
+ return True if self.config_default_role & ROLE_EDIT == ROLE_EDIT else False
+ else:
+ return False
+
+ def role_passwd(self):
+ if self.config_default_role is not None:
+ return True if self.config_default_role & ROLE_PASSWD == ROLE_PASSWD else False
+ else:
+ return False
+
def get_Log_Level(self):
ret_value=""
if self.config_log_level == logging.INFO:
@@ -337,6 +369,7 @@ def migrate_Database():
conn.execute("ALTER TABLE Settings ADD column `config_uploading` SmallInteger DEFAULT 0")
conn.execute("ALTER TABLE Settings ADD column `config_anonbrowse` SmallInteger DEFAULT 0")
conn.execute("ALTER TABLE Settings ADD column `config_public_reg` SmallInteger DEFAULT 0")
+ conn.execute("ALTER TABLE Settings ADD column `config_default_role` SmallInteger DEFAULT 0")
session.commit()
try:
session.query(exists().where(BookShelf.order)).scalar()
diff --git a/cps/web.py b/cps/web.py
index 465b7baa..88743405 100755
--- a/cps/web.py
+++ b/cps/web.py
@@ -1271,7 +1271,7 @@ def register():
content.password = generate_password_hash(to_save["password"])
content.nickname = to_save["nickname"]
content.email = to_save["email"]
- content.role = 0
+ content.role = config.config_default_role
try:
ub.session.add(content)
ub.session.commit()
@@ -1635,6 +1635,18 @@ def configuration_helper(origin):
content.config_anonbrowse = 1
if "config_public_reg" in to_save and to_save["config_public_reg"] == "on":
content.config_public_reg = 1
+
+ content.config_default_role = 0
+ if "admin_role" in to_save:
+ content.config_default_role = content.config_default_role + ub.ROLE_ADMIN
+ if "download_role" in to_save:
+ content.config_default_role = content.config_default_role + ub.ROLE_DOWNLOAD
+ if "upload_role" in to_save:
+ content.config_default_role = content.config_default_role + ub.ROLE_UPLOAD
+ if "edit_role" in to_save:
+ content.config_default_role = content.config_default_role + ub.ROLE_EDIT
+ if "passwd_role" in to_save:
+ content.config_default_role = content.config_default_role + ub.ROLE_PASSWD
try:
if db_change:
if config.db_configured: