~homeworkprod/byceps

386eb13ea22e28c2b44553063cd28c4ea70e4458 — Jochen Kupperschmidt 9 months ago e98b33e
Move permission registry module out of blueprints package
38 files changed, 37 insertions(+), 68 deletions(-)

M byceps/blueprints/admin/attendance/views.py
M byceps/blueprints/admin/authorization/views.py
M byceps/blueprints/admin/board/views.py
M byceps/blueprints/admin/brand/views.py
M byceps/blueprints/admin/consent/views.py
M byceps/blueprints/admin/core/views.py
M byceps/blueprints/admin/dashboard/views.py
M byceps/blueprints/admin/jobs/views.py
M byceps/blueprints/admin/news/views.py
M byceps/blueprints/admin/newsletter/views.py
M byceps/blueprints/admin/orga/views.py
M byceps/blueprints/admin/orga_presence/views.py
M byceps/blueprints/admin/orga_team/views.py
M byceps/blueprints/admin/party/views.py
M byceps/blueprints/admin/seating/views.py
M byceps/blueprints/admin/shop/article/views.py
M byceps/blueprints/admin/shop/email/views.py
M byceps/blueprints/admin/shop/order/views.py
M byceps/blueprints/admin/shop/shop/views.py
M byceps/blueprints/admin/site/views.py
M byceps/blueprints/admin/snippet/views.py
M byceps/blueprints/admin/terms/views.py
M byceps/blueprints/admin/ticketing/views.py
M byceps/blueprints/admin/tourney/category/views.py
M byceps/blueprints/admin/tourney/tourney/views.py
M byceps/blueprints/admin/user/views.py
M byceps/blueprints/admin/user_badge/views.py
M byceps/blueprints/admin/webhook/views.py
M byceps/blueprints/common/authentication/service.py
M byceps/blueprints/common/authorization/views.py
M byceps/blueprints/site/board/blueprint.py
M byceps/blueprints/site/news/views.py
M byceps/blueprints/site/seating/views.py
R byceps/{blueprints/common/authorization/registry.py => util/framework/permission_registry.py}
D tests/unit/blueprints/common/__init__.py
D tests/unit/blueprints/common/authorization/__init__.py
R tests/unit/{blueprints/__init__.py => util/framework/__init__.py}
R tests/unit/{blueprints/common/authorization/test_registry.py => util/framework/test_permission_registry.py}
M byceps/blueprints/admin/attendance/views.py => byceps/blueprints/admin/attendance/views.py +1 -2
@@ 13,11 13,10 @@ 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

from ...common.authorization.registry import permission_registry

from ..core.authorization import AdminPermission



M byceps/blueprints/admin/authorization/views.py => byceps/blueprints/admin/authorization/views.py +1 -2
@@ 11,11 11,10 @@ from flask import abort
from ....services.authorization import service as authorization_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

from ...common.authorization.registry import permission_registry

from .authorization import RolePermission



M byceps/blueprints/admin/board/views.py => byceps/blueprints/admin/board/views.py +1 -1
@@ 21,10 21,10 @@ from ....services.board.transfer.models import Board, Category
from ....services.brand import service as brand_service
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

from ...common.authorization.registry import permission_registry
from ...site.board.authorization import BoardPermission

from .authorization import BoardCategoryPermission

M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +1 -2
@@ 17,11 17,10 @@ from ....services.orga import service as orga_service
from ....services.party import service as party_service
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

from ...common.authorization.registry import permission_registry

from .authorization import BrandPermission
from .forms import CreateForm, EmailConfigUpdateForm, UpdateForm


M byceps/blueprints/admin/consent/views.py => byceps/blueprints/admin/consent/views.py +1 -2
@@ 8,11 8,10 @@ byceps.blueprints.admin.consent.views

from ....services.consent import subject_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

from ...common.authorization.registry import permission_registry

from .authorization import ConsentPermission



M byceps/blueprints/admin/core/views.py => byceps/blueprints/admin/core/views.py +1 -2
@@ 10,8 10,7 @@ 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 ...common.authorization.registry import permission_registry
from ....util.framework.permission_registry import permission_registry

from .authorization import AdminPermission


M byceps/blueprints/admin/dashboard/views.py => byceps/blueprints/admin/dashboard/views.py +1 -2
@@ 30,11 30,10 @@ 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.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

from ...common.authorization.registry import permission_registry

from ..user.service import get_users_created_since

from .authorization import AdminDashboardPermission

M byceps/blueprints/admin/jobs/views.py => byceps/blueprints/admin/jobs/views.py +1 -2
@@ 7,11 7,10 @@ byceps.blueprints.admin.jobs.views
"""

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

from ...common.authorization.registry import permission_registry

from .authorization import JobsPermission



M byceps/blueprints/admin/news/views.py => byceps/blueprints/admin/news/views.py +1 -2
@@ 23,13 23,12 @@ from ....signals import news as news_signals
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
from ....util.views import permission_required, redirect_to, respond_no_content

from ...common.authorization.registry import permission_registry

from .authorization import NewsChannelPermission, NewsItemPermission
from .forms import (
    ChannelCreateForm,

M byceps/blueprints/admin/newsletter/views.py => byceps/blueprints/admin/newsletter/views.py +1 -2
@@ 15,11 15,10 @@ from ....services.newsletter import service as newsletter_service
from ....services.newsletter.transfer.models import List
from ....services.newsletter.types import SubscriptionState
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

from ...common.authorization.registry import permission_registry

from .authorization import NewsletterPermission



M byceps/blueprints/admin/orga/views.py => byceps/blueprints/admin/orga/views.py +1 -2
@@ 18,6 18,7 @@ from ....services.user import service as user_service
from ....util.export import serialize_to_csv
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,


@@ 26,8 27,6 @@ from ....util.views import (
    textified,
)

from ...common.authorization.registry import permission_registry

from ..orga_team.authorization import OrgaTeamPermission

from .authorization import OrgaBirthdayPermission, OrgaDetailPermission

M byceps/blueprints/admin/orga_presence/views.py => byceps/blueprints/admin/orga_presence/views.py +1 -2
@@ 21,11 21,10 @@ from ....services.orga_presence.transfer.models import (
from ....services.party import service as party_service
from ....services.user.transfer.models import User
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

from ...common.authorization.registry import permission_registry

from .authorization import OrgaPresencePermission



M byceps/blueprints/admin/orga_team/views.py => byceps/blueprints/admin/orga_team/views.py +1 -2
@@ 13,11 13,10 @@ from ....services.party import service as party_service
from ....services.user import service as user_service
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

from ...common.authorization.registry import permission_registry

from .authorization import OrgaTeamPermission
from .forms import (
    MembershipCreateForm,

M byceps/blueprints/admin/party/views.py => byceps/blueprints/admin/party/views.py +1 -2
@@ 22,13 22,12 @@ from ....services.ticketing.transfer.models import TicketSaleStats
from ....typing import PartyID
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
from ....util.views import permission_required, redirect_to

from ...common.authorization.registry import permission_registry

from .authorization import PartyPermission
from .forms import CreateForm, UpdateForm


M byceps/blueprints/admin/seating/views.py => byceps/blueprints/admin/seating/views.py +1 -2
@@ 18,11 18,10 @@ from ....services.ticketing import (
    category_service as ticketing_category_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

from ...common.authorization.registry import permission_registry

from .authorization import SeatingPermission



M byceps/blueprints/admin/shop/article/views.py => byceps/blueprints/admin/shop/article/views.py +1 -2
@@ 26,12 26,11 @@ from .....services.shop.shop import service as shop_service
from .....services.user import service as user_service
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

from ....common.authorization.registry import permission_registry

from .authorization import ShopArticlePermission
from .forms import (
    ArticleCreateForm,

M byceps/blueprints/admin/shop/email/views.py => byceps/blueprints/admin/shop/email/views.py +1 -2
@@ 17,11 17,10 @@ from .....services.shop.order.email import (
)
from .....services.shop.shop import service as shop_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

from ....common.authorization.registry import permission_registry

from ..shop.authorization import ShopPermission



M byceps/blueprints/admin/shop/order/views.py => byceps/blueprints/admin/shop/order/views.py +1 -2
@@ 23,11 23,10 @@ from .....services.user import service as user_service
from .....signals import shop as shop_signals
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

from ....common.authorization.registry import permission_registry

from ..shop.authorization import ShopPermission
from .authorization import ShopOrderPermission
from .forms import CancelForm, MarkAsPaidForm, OrderNumberSequenceCreateForm

M byceps/blueprints/admin/shop/shop/views.py => byceps/blueprints/admin/shop/shop/views.py +1 -2
@@ 14,6 14,7 @@ from .....services.shop.order.transfer.models import PaymentState
from .....services.shop.shop import service as shop_service
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,


@@ 21,8 22,6 @@ from .....util.views import (
    respond_no_content_with_location,
)

from ....common.authorization.registry import permission_registry

from .authorization import ShopPermission



M byceps/blueprints/admin/site/views.py => byceps/blueprints/admin/site/views.py +1 -2
@@ 25,11 25,10 @@ from ....services.site import (
from ....services.site.transfer.models import Site, SiteWithBrand
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

from ...common.authorization.registry import permission_registry

from .authorization import SitePermission
from .forms import CreateForm, UpdateForm


M byceps/blueprints/admin/snippet/views.py => byceps/blueprints/admin/snippet/views.py +2 -2
@@ 17,8 17,9 @@ from ....signals import snippet as snippet_signals
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.iterables import pairwise
from ....util.framework.permission_registry import permission_registry
from ....util.framework.templating import templated
from ....util.iterables import pairwise
from ....util.views import (
    permission_required,
    redirect_to,


@@ 26,7 27,6 @@ from ....util.views import (
    respond_no_content_with_location,
)

from ...common.authorization.registry import permission_registry
from ...site.snippet.templating import get_snippet_context

from .authorization import SnippetMountpointPermission, SnippetPermission

M byceps/blueprints/admin/terms/views.py => byceps/blueprints/admin/terms/views.py +1 -2
@@ 13,11 13,10 @@ 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.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

from ...common.authorization.registry import permission_registry

from .authorization import TermsPermission



M byceps/blueprints/admin/ticketing/views.py => byceps/blueprints/admin/ticketing/views.py +1 -2
@@ 17,11 17,10 @@ from ....services.ticketing import (
)
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

from ...common.authorization.registry import permission_registry

from .authorization import TicketingPermission
from .forms import SpecifyUserForm, UpdateCodeForm
from . import service

M byceps/blueprints/admin/tourney/category/views.py => byceps/blueprints/admin/tourney/category/views.py +1 -2
@@ 12,11 12,10 @@ from .....services.party import service as party_service
from .....services.tourney import category_service
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

from ....common.authorization.registry import permission_registry

from ..authorization import TourneyCategoryPermission

from .forms import CreateForm, UpdateForm

M byceps/blueprints/admin/tourney/tourney/views.py => byceps/blueprints/admin/tourney/tourney/views.py +1 -2
@@ 15,12 15,11 @@ from .....services.party import service as party_service
from .....services.tourney import tourney_service
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

from ....common.authorization.registry import permission_registry

from ..authorization import TourneyPermission

from .forms import CreateForm, UpdateForm

M byceps/blueprints/admin/user/views.py => byceps/blueprints/admin/user/views.py +1 -2
@@ 29,11 29,10 @@ from ....services.user_badge import awarding_service as badge_awarding_service
from ....signals import user as user_signals
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

from ...common.authorization.registry import permission_registry

from ..authorization.authorization import RolePermission

from .authorization import UserPermission

M byceps/blueprints/admin/user_badge/views.py => byceps/blueprints/admin/user_badge/views.py +1 -2
@@ 14,11 14,10 @@ from ....services.user_badge import awarding_service, badge_service
from ....signals import user_badge as user_badge_signals
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

from ...common.authorization.registry import permission_registry

from .authorization import UserBadgePermission
from .forms import AwardForm, CreateForm, UpdateForm


M byceps/blueprints/admin/webhook/views.py => byceps/blueprints/admin/webhook/views.py +1 -2
@@ 8,11 8,10 @@ byceps.blueprints.admin.webhook.views

from ....services.webhooks import service as webhook_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

from ...common.authorization.registry import permission_registry

from .authorization import WebhookPermission



M byceps/blueprints/common/authentication/service.py => byceps/blueprints/common/authentication/service.py +1 -2
@@ 13,11 13,10 @@ from ....services.authentication.session.models.current_user import CurrentUser
from ....services.authorization import service as authorization_service
from ....services.user import event_service as user_event_service
from ....typing import PartyID, UserID
from ....util.framework.permission_registry import permission_registry

from ...admin.core.authorization import AdminPermission

from ..authorization.registry import permission_registry

from . import session as user_session



M byceps/blueprints/common/authorization/views.py => byceps/blueprints/common/authorization/views.py +1 -2
@@ 7,8 7,7 @@ byceps.blueprints.common.authorization.views
"""

from ....util.framework.blueprint import create_blueprint

from .registry import permission_registry
from ....util.framework.permission_registry import permission_registry


blueprint = create_blueprint('authorization', __name__)

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

from ....services.text_markup.service import render_html
from ....util.framework.blueprint import create_blueprint

from ...common.authorization.registry import permission_registry
from ....util.framework.permission_registry import permission_registry

from .authorization import (
    BoardPermission,

M byceps/blueprints/site/news/views.py => byceps/blueprints/site/news/views.py +1 -1
@@ 14,10 14,10 @@ from ....services.site import (
    settings_service as site_settings_service,
)
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
from ...common.authorization.registry import permission_registry


blueprint = create_blueprint('news', __name__)

M byceps/blueprints/site/seating/views.py => byceps/blueprints/site/seating/views.py +1 -1
@@ 22,11 22,11 @@ from ....services.ticketing import (
from ....services.ticketing.transfer.models import TicketID
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

from ...admin.seating.authorization import SeatingPermission
from ...common.authorization.registry import permission_registry

from . import service


R byceps/blueprints/common/authorization/registry.py => byceps/util/framework/permission_registry.py +2 -2
@@ 1,6 1,6 @@
"""
byceps.blueprints.common.authorization.registry
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
byceps.util.framework.permission_registry
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

D tests/unit/blueprints/common/__init__.py => tests/unit/blueprints/common/__init__.py +0 -0
D tests/unit/blueprints/common/authorization/__init__.py => tests/unit/blueprints/common/authorization/__init__.py +0 -0
R tests/unit/blueprints/__init__.py => tests/unit/util/framework/__init__.py +0 -0
R tests/unit/blueprints/common/authorization/test_registry.py => tests/unit/util/framework/test_permission_registry.py +1 -3
@@ 8,9 8,7 @@ from unittest.mock import patch
import pytest

with patch('flask.current_app'):
    from byceps.blueprints.common.authorization.registry import (
        PermissionRegistry,
    )
    from byceps.util.framework.permission_registry import PermissionRegistry
from byceps.util.authorization import create_permission_enum