aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/staff/tables/table_bare.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/tables/table_bare.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/tables/table_bare.py')
-rw-r--r--pysite/views/staff/tables/table_bare.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/pysite/views/staff/tables/table_bare.py b/pysite/views/staff/tables/table_bare.py
new file mode 100644
index 00000000..abd6cb19
--- /dev/null
+++ b/pysite/views/staff/tables/table_bare.py
@@ -0,0 +1,30 @@
+from flask import redirect, request, url_for
+from werkzeug.exceptions import NotFound
+
+from pysite.base_route import RouteView
+from pysite.constants import TABLE_MANAGER_ROLES
+from pysite.decorators import require_roles
+from pysite.mixins import DBMixin
+from pysite.tables import TABLES
+
+
+class TableView(RouteView, DBMixin):
+ path = "/tables/<table>"
+ name = "tables.table_bare"
+
+ @require_roles(*TABLE_MANAGER_ROLES)
+ def get(self, table):
+ if table not in TABLES:
+ raise NotFound()
+
+ search = request.args.get("search")
+
+ args = {
+ "table": table,
+ "page": 1
+ }
+
+ if search is not None:
+ args["search"] = search
+
+ return redirect(url_for("staff.tables.table", **args))