aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/staff/tables/table_bare.py
blob: abd6cb19e66a7cf92ffb241c40f8f49f60366f31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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))