aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/staff/index.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-05-14 20:42:41 +0100
committerGravatar GitHub <[email protected]>2018-05-14 20:42:41 +0100
commitb7fe5de12be5c9f02adeedba45befee751ea68be (patch)
tree740be4b7dff4a8e70616e1663375ef1940604d53 /pysite/views/staff/index.py
parentSwitch from using abort to using werkzeug exception (diff)
Migration runner and migrations (#69)
* Migration runner and migrations * Remove demo wiki data * [Staff] Table management pages * Fix weird travis build omission * Address review and comments by @Volcyy * [Tables] Fix pagination * Move table definitions to new file with nameduple * Linting * Address lemon's review comments * Address @Volcyy's review * Address lemon's review * Update search placeholder * Search by key now available
Diffstat (limited to 'pysite/views/staff/index.py')
-rw-r--r--pysite/views/staff/index.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/pysite/views/staff/index.py b/pysite/views/staff/index.py
index 11447f87..fc05f1a7 100644
--- a/pysite/views/staff/index.py
+++ b/pysite/views/staff/index.py
@@ -3,14 +3,29 @@ from pprint import pformat
from flask import current_app
from pysite.base_route import RouteView
-from pysite.constants import ALL_STAFF_ROLES
+from pysite.constants import ALL_STAFF_ROLES, DEBUG_MODE, TABLE_MANAGER_ROLES
from pysite.decorators import require_roles
class StaffView(RouteView):
path = "/"
- name = "index"
+ name = "staff_index"
@require_roles(*ALL_STAFF_ROLES)
def get(self):
- return self.render("staff/staff.html", app_config=pformat(current_app.config, indent=4, width=120))
+ return self.render(
+ "staff/staff.html", manager=self.is_table_editor(),
+ app_config=pformat(current_app.config, indent=4, width=120)
+ )
+
+ def is_table_editor(self):
+ if DEBUG_MODE:
+ return True
+
+ data = self.user_data
+
+ for role in TABLE_MANAGER_ROLES:
+ if role in data.get("roles", []):
+ return True
+
+ return False