~homeworkprod/byceps

1b14010f7688ee2e9a9849130762f509c30e3e1a — Jochen Kupperschmidt 9 months ago d7caf34
Introduce `byceps.util.authorization.register_permission_enum` to be used in blueprint views
M byceps/blueprints/admin/attendance/views.py => byceps/blueprints/admin/attendance/views.py +0 -1
@@ 13,7 13,6 @@ from ....services.party import service as party_service
from ....services.ticketing import attendance_service
from ....services.user import service as user_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required


M byceps/blueprints/admin/authorization/views.py => byceps/blueprints/admin/authorization/views.py +2 -2
@@ 10,8 10,8 @@ from flask import abort

from ....services.authorization import service as authorization_service
from ....services.user import service as user_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 21,7 21,7 @@ from .authorization import RolePermission
blueprint = create_blueprint('authorization_admin', __name__)


permission_registry.register_enum(RolePermission)
register_permission_enum(RolePermission)


@blueprint.route('/permissions')

M byceps/blueprints/admin/board/views.py => byceps/blueprints/admin/board/views.py +3 -3
@@ 19,9 19,9 @@ from ....services.board import (
)
from ....services.board.transfer.models import Board, Category
from ....services.brand import service as brand_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to, respond_no_content



@@ 34,8 34,8 @@ from .forms import BoardCreateForm, CategoryCreateForm, CategoryUpdateForm
blueprint = create_blueprint('board_admin', __name__)


permission_registry.register_enum(BoardPermission)
permission_registry.register_enum(BoardCategoryPermission)
register_permission_enum(BoardPermission)
register_permission_enum(BoardCategoryPermission)


@dataclass(frozen=True)

M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +2 -2
@@ 15,9 15,9 @@ from ....services.brand import (
from ....services.email import service as email_service
from ....services.orga import service as orga_service
from ....services.party import service as party_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to



@@ 28,7 28,7 @@ from .forms import CreateForm, EmailConfigUpdateForm, UpdateForm
blueprint = create_blueprint('brand_admin', __name__)


permission_registry.register_enum(BrandPermission)
register_permission_enum(BrandPermission)


@blueprint.route('/')

M byceps/blueprints/admin/consent/views.py => byceps/blueprints/admin/consent/views.py +2 -2
@@ 7,8 7,8 @@ byceps.blueprints.admin.consent.views
"""

from ....services.consent import subject_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 18,7 18,7 @@ from .authorization import ConsentPermission
blueprint = create_blueprint('consent_admin', __name__)


permission_registry.register_enum(ConsentPermission)
register_permission_enum(ConsentPermission)


@blueprint.route('/')

M byceps/blueprints/admin/core/views.py => byceps/blueprints/admin/core/views.py +2 -2
@@ 9,8 9,8 @@ byceps.blueprints.admin.core.views
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 ....util.framework.permission_registry import permission_registry

from .authorization import AdminPermission



@@ 18,7 18,7 @@ from .authorization import AdminPermission
blueprint = create_blueprint('core_admin', __name__)


permission_registry.register_enum(AdminPermission)
register_permission_enum(AdminPermission)


@blueprint.app_context_processor

M byceps/blueprints/admin/dashboard/views.py => byceps/blueprints/admin/dashboard/views.py +2 -2
@@ 29,8 29,8 @@ from ....services.shop.shop import service as shop_service
from ....services.site import service as site_service
from ....services.ticketing import ticket_service
from ....services.user import stats_service as user_stats_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 42,7 42,7 @@ from .authorization import AdminDashboardPermission
blueprint = create_blueprint('admin_dashboard', __name__)


permission_registry.register_enum(AdminDashboardPermission)
register_permission_enum(AdminDashboardPermission)


@blueprint.route('')

M byceps/blueprints/admin/jobs/views.py => byceps/blueprints/admin/jobs/views.py +2 -2
@@ 6,8 6,8 @@ byceps.blueprints.admin.jobs.views
:License: Revised BSD (see `LICENSE` file for details)
"""

from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 17,7 17,7 @@ from .authorization import JobsPermission
blueprint = create_blueprint('jobs_admin', __name__)


permission_registry.register_enum(JobsPermission)
register_permission_enum(JobsPermission)


@blueprint.route('/')

M byceps/blueprints/admin/news/views.py => byceps/blueprints/admin/news/views.py +3 -3
@@ 20,10 20,10 @@ from ....services.news.transfer.models import Channel
from ....services.text_diff import service as text_diff_service
from ....services.user.service import UserIdRejected
from ....signals import news as news_signals
from ....util.authorization import register_permission_enum
from ....util.datetime.format import format_datetime_short
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.iterables import pairwise
from ....util.templatefilters import local_tz_to_utc


@@ 43,8 43,8 @@ from .forms import (
blueprint = create_blueprint('news_admin', __name__)


permission_registry.register_enum(NewsChannelPermission)
permission_registry.register_enum(NewsItemPermission)
register_permission_enum(NewsChannelPermission)
register_permission_enum(NewsItemPermission)


# -------------------------------------------------------------------- #

M byceps/blueprints/admin/newsletter/views.py => byceps/blueprints/admin/newsletter/views.py +2 -2
@@ 14,8 14,8 @@ from flask import abort
from ....services.newsletter import service as newsletter_service
from ....services.newsletter.transfer.models import List
from ....services.newsletter.types import SubscriptionState
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import jsonified, permission_required, textified



@@ 25,7 25,7 @@ from .authorization import NewsletterPermission
blueprint = create_blueprint('newsletter_admin', __name__)


permission_registry.register_enum(NewsletterPermission)
register_permission_enum(NewsletterPermission)


@dataclass(frozen=True)

M byceps/blueprints/admin/orga/views.py => byceps/blueprints/admin/orga/views.py +4 -4
@@ 16,9 16,9 @@ from ....services.orga import service as orga_service
from ....services.orga.transfer.models import Birthday
from ....services.user import service as user_service
from ....util.export import serialize_to_csv
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import (
    permission_required,


@@ 36,9 36,9 @@ from .forms import OrgaFlagCreateForm
blueprint = create_blueprint('orga_admin', __name__)


permission_registry.register_enum(OrgaBirthdayPermission)
permission_registry.register_enum(OrgaDetailPermission)
permission_registry.register_enum(OrgaTeamPermission)
register_permission_enum(OrgaBirthdayPermission)
register_permission_enum(OrgaDetailPermission)
register_permission_enum(OrgaTeamPermission)


@blueprint.route('/persons/<brand_id>')

M byceps/blueprints/admin/orga_presence/views.py => byceps/blueprints/admin/orga_presence/views.py +2 -2
@@ 20,8 20,8 @@ from ....services.orga_presence.transfer.models import (
)
from ....services.party import service as party_service
from ....services.user.transfer.models import User
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 31,7 31,7 @@ from .authorization import OrgaPresencePermission
blueprint = create_blueprint('orga_presence', __name__)


permission_registry.register_enum(OrgaPresencePermission)
register_permission_enum(OrgaPresencePermission)


@blueprint.route('/<party_id>')

M byceps/blueprints/admin/orga_team/views.py => byceps/blueprints/admin/orga_team/views.py +2 -2
@@ 11,9 11,9 @@ from flask import abort, request
from ....services.orga_team import service as orga_team_service
from ....services.party import service as party_service
from ....services.user import service as user_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to, respond_no_content



@@ 29,7 29,7 @@ from .forms import (
blueprint = create_blueprint('orga_team_admin', __name__)


permission_registry.register_enum(OrgaTeamPermission)
register_permission_enum(OrgaTeamPermission)


# -------------------------------------------------------------------- #

M byceps/blueprints/admin/party/views.py => byceps/blueprints/admin/party/views.py +2 -2
@@ 20,9 20,9 @@ from ....services.party import (
from ....services.ticketing import ticket_service
from ....services.ticketing.transfer.models import TicketSaleStats
from ....typing import PartyID
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.iterables import partition
from ....util.templatefilters import local_tz_to_utc, utc_to_local_tz


@@ 35,7 35,7 @@ from .forms import CreateForm, UpdateForm
blueprint = create_blueprint('party_admin', __name__)


permission_registry.register_enum(PartyPermission)
register_permission_enum(PartyPermission)


@blueprint.route('/')

M byceps/blueprints/admin/seating/views.py => byceps/blueprints/admin/seating/views.py +2 -2
@@ 17,8 17,8 @@ from ....services.seating import (
from ....services.ticketing import (
    category_service as ticketing_category_service,
)
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 28,7 28,7 @@ from .authorization import SeatingPermission
blueprint = create_blueprint('seating_admin', __name__)


permission_registry.register_enum(SeatingPermission)
register_permission_enum(SeatingPermission)


@blueprint.route('/<party_id>')

M byceps/blueprints/admin/shop/article/views.py => byceps/blueprints/admin/shop/article/views.py +2 -2
@@ 24,9 24,9 @@ from .....services.shop.order import (
from .....services.shop.order.transfer.models import PaymentState
from .....services.shop.shop import service as shop_service
from .....services.user import service as user_service
from .....util.authorization import register_permission_enum
from .....util.framework.blueprint import create_blueprint
from .....util.framework.flash import flash_error, flash_success
from .....util.framework.permission_registry import permission_registry
from .....util.framework.templating import templated
from .....util.templatefilters import local_tz_to_utc, utc_to_local_tz
from .....util.views import permission_required, redirect_to, respond_no_content


@@ 43,7 43,7 @@ from .forms import (
blueprint = create_blueprint('shop_article_admin', __name__)


permission_registry.register_enum(ShopArticlePermission)
register_permission_enum(ShopArticlePermission)


TAX_RATE_DISPLAY_FACTOR = Decimal('100')

M byceps/blueprints/admin/shop/email/views.py => byceps/blueprints/admin/shop/email/views.py +2 -2
@@ 16,8 16,8 @@ from .....services.shop.order.email import (
    example_service as example_order_email_service,
)
from .....services.shop.shop import service as shop_service
from .....util.authorization import register_permission_enum
from .....util.framework.blueprint import create_blueprint
from .....util.framework.permission_registry import permission_registry
from .....util.framework.templating import templated
from .....util.views import permission_required



@@ 27,7 27,7 @@ from ..shop.authorization import ShopPermission
blueprint = create_blueprint('shop_email_admin', __name__)


permission_registry.register_enum(ShopPermission)
register_permission_enum(ShopPermission)


@blueprint.route('/for_shop/<shop_id>')

M byceps/blueprints/admin/shop/order/views.py => byceps/blueprints/admin/shop/order/views.py +2 -2
@@ 21,9 21,9 @@ from .....services.shop.shop import service as shop_service
from .....services.ticketing import ticket_service
from .....services.user import service as user_service
from .....signals import shop as shop_signals
from .....util.authorization import register_permission_enum
from .....util.framework.blueprint import create_blueprint
from .....util.framework.flash import flash_error, flash_notice, flash_success
from .....util.framework.permission_registry import permission_registry
from .....util.framework.templating import templated
from .....util.views import permission_required, redirect_to, respond_no_content



@@ 37,7 37,7 @@ from . import service
blueprint = create_blueprint('shop_order_admin', __name__)


permission_registry.register_enum(ShopOrderPermission)
register_permission_enum(ShopOrderPermission)


@blueprint.route('/for_shop/<shop_id>', defaults={'page': 1})

M byceps/blueprints/admin/shop/shop/views.py => byceps/blueprints/admin/shop/shop/views.py +2 -2
@@ 12,9 12,9 @@ from .....services.brand import service as brand_service
from .....services.shop.order import service as order_service
from .....services.shop.order.transfer.models import PaymentState
from .....services.shop.shop import service as shop_service
from .....util.authorization import register_permission_enum
from .....util.framework.blueprint import create_blueprint
from .....util.framework.flash import flash_success
from .....util.framework.permission_registry import permission_registry
from .....util.framework.templating import templated
from .....util.views import (
    permission_required,


@@ 28,7 28,7 @@ from .authorization import ShopPermission
blueprint = create_blueprint('shop_shop_admin', __name__)


permission_registry.register_enum(ShopPermission)
register_permission_enum(ShopPermission)


@blueprint.route('/for_shop/<shop_id>')

M byceps/blueprints/admin/site/views.py => byceps/blueprints/admin/site/views.py +2 -2
@@ 23,9 23,9 @@ from ....services.site import (
    settings_service as site_settings_service,
)
from ....services.site.transfer.models import Site, SiteWithBrand
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to



@@ 36,7 36,7 @@ from .forms import CreateForm, UpdateForm
blueprint = create_blueprint('site_admin', __name__)


permission_registry.register_enum(SitePermission)
register_permission_enum(SitePermission)


@blueprint.route('/')

M byceps/blueprints/admin/snippet/views.py => byceps/blueprints/admin/snippet/views.py +3 -3
@@ 14,10 14,10 @@ from ....services.snippet import mountpoint_service, service as snippet_service
from ....services.snippet.transfer.models import Scope
from ....services.text_diff import service as text_diff_service
from ....signals import snippet as snippet_signals
from ....util.authorization import register_permission_enum
from ....util.datetime.format import format_datetime_short
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.iterables import pairwise
from ....util.views import (


@@ 41,8 41,8 @@ from .forms import (
blueprint = create_blueprint('snippet_admin', __name__)


permission_registry.register_enum(SnippetMountpointPermission)
permission_registry.register_enum(SnippetPermission)
register_permission_enum(SnippetMountpointPermission)
register_permission_enum(SnippetPermission)


@blueprint.route('/for_scope/<scope_type>/<scope_name>')

M byceps/blueprints/admin/terms/views.py => byceps/blueprints/admin/terms/views.py +2 -2
@@ 12,8 12,8 @@ from ....services.terms import consent_service as terms_consent_service
from ....services.terms import document_service as terms_document_service
from ....services.terms import version_service as terms_version_service
from ....services.user import service as user_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 23,7 23,7 @@ from .authorization import TermsPermission
blueprint = create_blueprint('terms_admin', __name__)


permission_registry.register_enum(TermsPermission)
register_permission_enum(TermsPermission)


@blueprint.route('/documents/<document_id>')

M byceps/blueprints/admin/ticketing/views.py => byceps/blueprints/admin/ticketing/views.py +2 -2
@@ 15,9 15,9 @@ from ....services.ticketing import (
    ticket_service,
    ticket_user_management_service,
)
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to



@@ 29,7 29,7 @@ from . import service
blueprint = create_blueprint('ticketing_admin', __name__)


permission_registry.register_enum(TicketingPermission)
register_permission_enum(TicketingPermission)


# -------------------------------------------------------------------- #

M byceps/blueprints/admin/tourney/category/views.py => byceps/blueprints/admin/tourney/category/views.py +2 -2
@@ 10,9 10,9 @@ from flask import abort, request

from .....services.party import service as party_service
from .....services.tourney import category_service
from .....util.authorization import register_permission_enum
from .....util.framework.blueprint import create_blueprint
from .....util.framework.flash import flash_error, flash_success
from .....util.framework.permission_registry import permission_registry
from .....util.framework.templating import templated
from .....util.views import permission_required, redirect_to, respond_no_content



@@ 24,7 24,7 @@ from .forms import CreateForm, UpdateForm
blueprint = create_blueprint('tourney_category_admin', __name__)


permission_registry.register_enum(TourneyCategoryPermission)
register_permission_enum(TourneyCategoryPermission)


@blueprint.route('/for_party/<party_id>')

M byceps/blueprints/admin/tourney/tourney/views.py => byceps/blueprints/admin/tourney/tourney/views.py +2 -2
@@ 13,9 13,9 @@ from flask import abort, request

from .....services.party import service as party_service
from .....services.tourney import tourney_service
from .....util.authorization import register_permission_enum
from .....util.framework.blueprint import create_blueprint
from .....util.framework.flash import flash_success
from .....util.framework.permission_registry import permission_registry
from .....util.framework.templating import templated
from .....util.templatefilters import local_tz_to_utc, utc_to_local_tz
from .....util.views import permission_required, redirect_to


@@ 28,7 28,7 @@ from .forms import CreateForm, UpdateForm
blueprint = create_blueprint('tourney_tourney_admin', __name__)


permission_registry.register_enum(TourneyPermission)
register_permission_enum(TourneyPermission)


@blueprint.route('/for_party/<party_id>')

M byceps/blueprints/admin/user/views.py => byceps/blueprints/admin/user/views.py +2 -2
@@ 27,9 27,9 @@ from ....services.user import service as user_service
from ....services.user import stats_service as user_stats_service
from ....services.user_badge import awarding_service as badge_awarding_service
from ....signals import user as user_signals
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to, respond_no_content



@@ 51,7 51,7 @@ from . import service
blueprint = create_blueprint('user_admin', __name__)


permission_registry.register_enum(UserPermission)
register_permission_enum(UserPermission)


@blueprint.route('/', defaults={'page': 1})

M byceps/blueprints/admin/user_badge/views.py => byceps/blueprints/admin/user_badge/views.py +2 -2
@@ 12,9 12,9 @@ from ....services.brand import service as brand_service
from ....services.user import service as user_service
from ....services.user_badge import awarding_service, badge_service
from ....signals import user_badge as user_badge_signals
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required, redirect_to



@@ 25,7 25,7 @@ from .forms import AwardForm, CreateForm, UpdateForm
blueprint = create_blueprint('user_badge_admin', __name__)


permission_registry.register_enum(UserBadgePermission)
register_permission_enum(UserBadgePermission)


# -------------------------------------------------------------------- #

M byceps/blueprints/admin/webhook/views.py => byceps/blueprints/admin/webhook/views.py +2 -2
@@ 7,8 7,8 @@ byceps.blueprints.admin.webhook.views
"""

from ....services.webhooks import service as webhook_service
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import permission_required



@@ 18,7 18,7 @@ from .authorization import WebhookPermission
blueprint = create_blueprint('webhook_admin', __name__)


permission_registry.register_enum(WebhookPermission)
register_permission_enum(WebhookPermission)


@blueprint.route('/')

M byceps/blueprints/site/board/blueprint.py => byceps/blueprints/site/board/blueprint.py +4 -4
@@ 7,8 7,8 @@ byceps.blueprints.site.board.blueprint
"""

from ....services.text_markup.service import render_html
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry

from .authorization import (
    BoardPermission,


@@ 23,6 23,6 @@ blueprint = create_blueprint('board', __name__)
blueprint.add_app_template_filter(render_html, 'bbcode')


permission_registry.register_enum(BoardPermission)
permission_registry.register_enum(BoardTopicPermission)
permission_registry.register_enum(BoardPostingPermission)
register_permission_enum(BoardPermission)
register_permission_enum(BoardTopicPermission)
register_permission_enum(BoardPostingPermission)

M byceps/blueprints/site/news/views.py => byceps/blueprints/site/news/views.py +2 -2
@@ 13,8 13,8 @@ from ....services.site import (
    service as site_service,
    settings_service as site_settings_service,
)
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated

from ...admin.news.authorization import NewsItemPermission


@@ 23,7 23,7 @@ from ...admin.news.authorization import NewsItemPermission
blueprint = create_blueprint('news', __name__)


permission_registry.register_enum(NewsItemPermission)
register_permission_enum(NewsItemPermission)


DEFAULT_ITEMS_PER_PAGE = 4

M byceps/blueprints/site/seating/views.py => byceps/blueprints/site/seating/views.py +2 -2
@@ 20,9 20,9 @@ from ....services.ticketing import (
    ticket_service,
)
from ....services.ticketing.transfer.models import TicketID
from ....util.authorization import register_permission_enum
from ....util.framework.blueprint import create_blueprint
from ....util.framework.flash import flash_error, flash_success
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.views import login_required, redirect_to, respond_no_content



@@ 34,7 34,7 @@ from . import service
blueprint = create_blueprint('seating', __name__)


permission_registry.register_enum(SeatingPermission)
register_permission_enum(SeatingPermission)


@blueprint.route('/')

M byceps/util/authorization.py => byceps/util/authorization.py +9 -2
@@ 9,10 9,12 @@ byceps.util.authorization
from enum import Enum
from typing import List

from .framework.permission_registry import permission_registry


def create_permission_enum(key: str, member_names: List[str]) -> Enum:
    """Create a permission enum."""
    name = derive_name(key)
    name = _derive_enum_name(key)

    permission_enum = Enum(name, list(member_names))
    permission_enum.__key__ = key


@@ 21,9 23,14 @@ def create_permission_enum(key: str, member_names: List[str]) -> Enum:
    return permission_enum


def derive_name(key: str) -> str:
def _derive_enum_name(key: str) -> str:
    """Derive a `CamelCase` name from the `underscore_separated_key`."""
    words = key.split('_')
    words.append('permission')

    return ''.join(word.title() for word in words)


def register_permission_enum(enum: Enum):
    """Register permission enum."""
    permission_registry.register_enum(enum)