~homeworkprod/byceps

ref: 9d03914c72973f3aaa42044ceb849cac91ac79c9 byceps/byceps/blueprints/admin/core/views.py -rw-r--r-- 1.2 KiB
9d03914c — Jochen Kupperschmidt Move link to news channel index from admin brand "more" page to admin brand navigation 1 year, 7 days 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
"""
byceps.blueprints.admin.core.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint

from .authorization import AdminPermission


blueprint = create_blueprint('core_admin', __name__)


register_permission_enum(AdminPermission)


@blueprint.app_context_processor
def inject_template_variables():
    brands = brand_service.get_all_brands()

    def get_brand_for_site(site):
        return brand_service.find_brand(site.brand_id)

    def get_brand_for_party(party):
        return brand_service.find_brand(party.brand_id)

    return {
        'all_brands': brands,
        'get_brand_for_site': get_brand_for_site,
        'get_brand_for_party': get_brand_for_party,
        'get_sites_for_brand': site_service.get_sites_for_brand,
        'get_parties_for_brand': party_service.get_parties_for_brand,
    }