From c7b7b3866e25f4539b2d430ba7235adaf16bc580 Mon Sep 17 00:00:00 2001 From: Cervinko Cera Date: Wed, 27 Apr 2016 10:35:23 +0200 Subject: [PATCH] add user-permission management --- cps/config.py | 4 + cps/templates/detail.html | 2 +- cps/templates/layout.html | 4 +- cps/templates/user_edit.html | 16 ++- cps/templates/user_list.html | 9 +- cps/ub.py | 233 +++++++++++++++++++---------------- cps/web.py | 120 +++++++++++++++--- 7 files changed, 263 insertions(+), 125 deletions(-) diff --git a/cps/config.py b/cps/config.py index f3ff809e..0cd77b29 100755 --- a/cps/config.py +++ b/cps/config.py @@ -60,6 +60,7 @@ TITLE_REGEX = check_setting_str(CFG, 'Advanced', 'TITLE_REGEX', '^(A|The|An|Der| DEVELOPMENT = bool(check_setting_int(CFG, 'Advanced', 'DEVELOPMENT', 0)) PUBLIC_REG = bool(check_setting_int(CFG, 'Advanced', 'PUBLIC_REG', 0)) UPLOADING = bool(check_setting_int(CFG, 'Advanced', 'UPLOADING', 0)) +ANO_SHOW_BOOKS = bool(check_setting_int(CFG, 'Advanced', 'ANO_SHOW_BOOKS', 0)) SYS_ENCODING="UTF-8" @@ -78,6 +79,8 @@ configval["DEVELOPMENT"] = DEVELOPMENT configval["TITLE_REGEX"] = TITLE_REGEX configval["PUBLIC_REG"] = PUBLIC_REG configval["UPLOADING"] = UPLOADING +configval["ANO_SHOW_BOOKS"] = ANO_SHOW_BOOKS + def save_config(configval): new_config = ConfigObj() @@ -94,6 +97,7 @@ def save_config(configval): new_config['Advanced']['DEVELOPMENT'] = int(configval["DEVELOPMENT"]) new_config['Advanced']['PUBLIC_REG'] = int(configval["PUBLIC_REG"]) new_config['Advanced']['UPLOADING'] = int(configval["UPLOADING"]) + new_config['Advanced']['ANO_SHOW_BOOKS'] = int(configval["ANO_SHOW_BOOKS"]) new_config.write() return "Saved" diff --git a/cps/templates/detail.html b/cps/templates/detail.html index b6d5018b..035a795b 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -154,7 +154,7 @@ {% endif %} - {% if g.user.role %} + {% if g.user.role_edit() %}