summaryrefslogtreecommitdiffstats
path: root/module/web/utils.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-19 21:58:08 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-19 21:58:08 +0100
commit63f8af1fc3049527a4a4b53a1bbfde90cb4b2eb3 (patch)
tree8227674ebd87c28df53bad55de401a9264a283b4 /module/web/utils.py
parentfixed cli unicode error (diff)
downloadpyload-63f8af1fc3049527a4a4b53a1bbfde90cb4b2eb3.tar.xz
encoding fixes
Diffstat (limited to 'module/web/utils.py')
-rw-r--r--module/web/utils.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/module/web/utils.py b/module/web/utils.py
index f738560f7..8674fea1c 100644
--- a/module/web/utils.py
+++ b/module/web/utils.py
@@ -20,6 +20,8 @@ from bottle import request, HTTPError, redirect, ServerAdapter
from webinterface import env, TEMPLATE
+from module.database.UserDatabase import has_permission, PERMS, ROLE
+
def render_to_response(name, args={}, proc=[]):
for p in proc:
args.update(p())
@@ -28,14 +30,27 @@ def render_to_response(name, args={}, proc=[]):
return t.render(**args)
def parse_permissions(session):
- perms = {"can_change_status": False,
- "can_see_dl": False}
+ perms = {"add": False,
+ "delete": False,
+ "status": False,
+ "see_downloads": False,
+ "download" : False,
+ "settings": False}
if not session.get("authenticated", False):
return perms
- perms["can_change_status"] = True
- perms["can_see_dl"] = True
+ if session.get("role") == ROLE.ADMIN:
+ for k in perms.iterkeys():
+ perms[k] = True
+ else:
+ p = session.get("permission")
+ perms["add"] = has_permission(p, PERMS.ADD)
+ perms["delete"] = has_permission(p, PERMS.DELETE)
+ perms["status"] = has_permission(p, PERMS.STATUS)
+ perms["see_downloads"] = has_permission(p, PERMS.SEE_DOWNLOADS)
+ perms["download"] = has_permission(p, PERMS.DOWNLOAD)
+ perms["settings"] = has_permission(p, PERMS.SETTINGS)
return perms