~homeworkprod/byceps

ref: 533662eefb314d54b168e5a46bc07c88b5f88be4 byceps/byceps/blueprints/admin/more/views.py -rw-r--r-- 1.6 KiB
533662ee — Jochen Kupperschmidt Use Flask v2.0's `delete`/`get`/`patch`/`post` route shortcuts 2 months ago
                                                                                
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
byceps.blueprints.admin.more.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2021 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

from flask import abort

from ....services.brand import service as brand_service
from ....services.party import service as party_service
from ....services.site import service as site_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated
from ....util.views import permission_required

from ..core.authorization import AdminPermission


blueprint = create_blueprint('more_admin', __name__)


@blueprint.get('/global')
@permission_required(AdminPermission.access)
@templated
def view_global():
    """Show more global admin items."""
    return {}


@blueprint.get('/brands/<brand_id>')
@permission_required(AdminPermission.access)
@templated
def view_brand(brand_id):
    """Show more brand admin items."""
    brand = brand_service.find_brand(brand_id)
    if brand is None:
        abort(404)

    return {'brand': brand}


@blueprint.get('/parties/<party_id>')
@permission_required(AdminPermission.access)
@templated
def view_party(party_id):
    """Show more party admin items."""
    party = party_service.find_party(party_id)
    if party is None:
        abort(404)

    return {'party': party}


@blueprint.get('/sites/<site_id>')
@permission_required(AdminPermission.access)
@templated
def view_site(site_id):
    """Show more site admin items."""
    site = site_service.find_site(site_id)
    if site is None:
        abort(404)

    return {'site': site}