~homeworkprod/byceps

97cfc47327a385251be99a69d1d0a7bb692e58fb — Jochen Kupperschmidt 1 year, 2 months ago 49d49a2
Move authorization blueprint into `common` subpackage
41 files changed, 72 insertions(+), 69 deletions(-)

M byceps/application.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/email/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/shipping/views.py
M byceps/blueprints/admin/shop/shop/views.py
M byceps/blueprints/admin/shop/storefront/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/checkin/views.py
M byceps/blueprints/admin/ticketing/views.py
M byceps/blueprints/admin/tourney/views.py
M byceps/blueprints/admin/user/views.py
M byceps/blueprints/admin/user_badge/views.py
M byceps/blueprints/common/authentication/service.py
R byceps/blueprints/{authorization/__init__.py => common/authorization/__init__.py}
R byceps/blueprints/{authorization/decorators.py => common/authorization/decorators.py}
R byceps/blueprints/{authorization/registry.py => common/authorization/registry.py}
R byceps/blueprints/{authorization/views.py => common/authorization/views.py}
M byceps/blueprints/site/board/blueprint.py
M byceps/blueprints/site/board/views_posting.py
M byceps/blueprints/site/board/views_topic.py
M byceps/blueprints/site/news/views.py
M byceps/blueprints/site/seating/views.py
M tests/unit/blueprints/authorization/test_registry.py
M byceps/application.py => byceps/application.py +1 -1
@@ 99,7 99,7 @@ def _get_blueprints(app: Flask) -> Iterator[BlueprintReg]:
def _get_blueprints_common() -> Iterator[BlueprintReg]:
    yield from [
        ('common.authentication',       '/authentication'           ),
        ('authorization',               None                        ),
        ('common.authorization',        None                        ),
        ('core',                        '/core'                     ),
        ('common.user',                 None                        ),
        ('common.user.avatar',          '/users'                    ),

M byceps/blueprints/admin/authorization/views.py => byceps/blueprints/admin/authorization/views.py +2 -2
@@ 13,8 13,8 @@ from ....services.user import service as user_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators 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 +2 -2
@@ 24,8 24,8 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to, respond_no_content

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
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 +2 -2
@@ 19,8 19,8 @@ from ....util.framework.flash import flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import BrandPermission
from .forms import CreateForm

M byceps/blueprints/admin/consent/views.py => byceps/blueprints/admin/consent/views.py +2 -2
@@ 10,8 10,8 @@ from ....services.consent import subject_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators 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 -1
@@ 11,7 11,7 @@ from ....services.party import service as party_service
from ....services.site import service as site_service
from ....util.framework.blueprint import create_blueprint

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

from .authorization import AdminPermission


M byceps/blueprints/admin/dashboard/views.py => byceps/blueprints/admin/dashboard/views.py +2 -2
@@ 30,8 30,8 @@ from ....services.user import stats_service as user_stats_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from ..user.service import get_users_created_since


M byceps/blueprints/admin/email/views.py => byceps/blueprints/admin/email/views.py +2 -2
@@ 10,8 10,8 @@ from ....services.email import service as email_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import EmailConfigPermission


M byceps/blueprints/admin/jobs/views.py => byceps/blueprints/admin/jobs/views.py +2 -2
@@ 9,8 9,8 @@ byceps.blueprints.admin.jobs.views
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators 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 +2 -2
@@ 27,8 27,8 @@ from ....util.framework.templating import templated
from ....util.iterables import pairwise
from ....util.views import redirect_to, respond_no_content

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

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

M byceps/blueprints/admin/newsletter/views.py => byceps/blueprints/admin/newsletter/views.py +2 -2
@@ 18,8 18,8 @@ from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated
from ....util.views import jsonified, textified

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import NewsletterPermission


M byceps/blueprints/admin/orga/views.py => byceps/blueprints/admin/orga/views.py +2 -2
@@ 20,8 20,8 @@ from ....util.framework.flash import flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to, respond_no_content, textified

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from ..orga_team.authorization import OrgaTeamPermission


M byceps/blueprints/admin/orga_presence/views.py => byceps/blueprints/admin/orga_presence/views.py +2 -2
@@ 23,8 23,8 @@ from ....services.user.transfer.models import User
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators 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 +2 -2
@@ 16,8 16,8 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to, respond_no_content

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import OrgaTeamPermission
from .forms import (

M byceps/blueprints/admin/party/views.py => byceps/blueprints/admin/party/views.py +2 -2
@@ 22,8 22,8 @@ from ....util.framework.templating import templated
from ....util.templatefilters import local_tz_to_utc, utc_to_local_tz
from ....util.views import redirect_to

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
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 +2 -2
@@ 20,8 20,8 @@ from ....services.ticketing import (
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators 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 +2 -2
@@ 26,8 26,8 @@ from .....util.framework.templating import templated
from .....util.templatefilters import local_tz_to_utc, utc_to_local_tz
from .....util.views import redirect_to, respond_no_content

from ....authorization.decorators import permission_required
from ....authorization.registry import permission_registry
from ....common.authorization.decorators import permission_required
from ....common.authorization.registry import permission_registry

from .authorization import ShopArticlePermission
from .forms import (

M byceps/blueprints/admin/shop/email/views.py => byceps/blueprints/admin/shop/email/views.py +2 -2
@@ 26,8 26,8 @@ from .....util.framework.flash import flash_error
from .....util.framework.templating import templated
from .....util.views import redirect_to

from ....authorization.decorators import permission_required
from ....authorization.registry import permission_registry
from ....common.authorization.decorators 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 +2 -2
@@ 21,8 21,8 @@ from .....util.framework.flash import flash_error, flash_notice, flash_success
from .....util.framework.templating import templated
from .....util.views import redirect_to, respond_no_content

from ....authorization.decorators import permission_required
from ....authorization.registry import permission_registry
from ....common.authorization.decorators import permission_required
from ....common.authorization.registry import permission_registry

from .authorization import ShopOrderPermission
from .forms import CancelForm, MarkAsPaidForm

M byceps/blueprints/admin/shop/shipping/views.py => byceps/blueprints/admin/shop/shipping/views.py +1 -1
@@ 13,7 13,7 @@ from .....services.shop.shop import service as shop_service
from .....util.framework.blueprint import create_blueprint
from .....util.framework.templating import templated

from ....authorization.decorators import permission_required
from ....common.authorization.decorators import permission_required

from ..order.authorization import ShopOrderPermission


M byceps/blueprints/admin/shop/shop/views.py => byceps/blueprints/admin/shop/shop/views.py +2 -2
@@ 22,8 22,8 @@ from .....util.framework.flash import flash_success
from .....util.framework.templating import templated
from .....util.views import redirect_to

from ....authorization.decorators import permission_required
from ....authorization.registry import permission_registry
from ....common.authorization.decorators import permission_required
from ....common.authorization.registry import permission_registry

from .authorization import ShopPermission
from .forms import CreateForm

M byceps/blueprints/admin/shop/storefront/views.py => byceps/blueprints/admin/shop/storefront/views.py +1 -1
@@ 17,7 17,7 @@ from .....util.framework.flash import flash_error, flash_success
from .....util.framework.templating import templated
from .....util.views import redirect_to

from ....authorization.decorators import permission_required
from ....common.authorization.decorators import permission_required

from ..shop.authorization import ShopPermission


M byceps/blueprints/admin/site/views.py => byceps/blueprints/admin/site/views.py +2 -2
@@ 23,8 23,8 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
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
@@ 25,8 25,8 @@ from ....util.views import (
    respond_no_content_with_location,
)

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
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 +2 -2
@@ 15,8 15,8 @@ from ....services.user import service as user_service
from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import TermsPermission


M byceps/blueprints/admin/ticketing/checkin/views.py => byceps/blueprints/admin/ticketing/checkin/views.py +1 -1
@@ 15,7 15,7 @@ from .....services.ticketing import ticket_service
from .....util.framework.blueprint import create_blueprint
from .....util.framework.templating import templated

from ....authorization.decorators import permission_required
from ....common.authorization.decorators import permission_required

from ...ticketing.authorization import TicketingPermission
from ...user import service as user_blueprint_service

M byceps/blueprints/admin/ticketing/views.py => byceps/blueprints/admin/ticketing/views.py +2 -2
@@ 23,8 23,8 @@ from ....util.framework.flash import flash_error, flash_notice, flash_success
from ....util.framework.templating import templated
from ....util.views import respond_no_content

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import TicketingPermission
from .forms import SpecifyUserForm

M byceps/blueprints/admin/tourney/views.py => byceps/blueprints/admin/tourney/views.py +2 -2
@@ 15,8 15,8 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to, respond_no_content

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from .authorization import TourneyCategoryPermission
from .forms import TourneyCategoryCreateForm, TourneyCategoryUpdateForm

M byceps/blueprints/admin/user/views.py => byceps/blueprints/admin/user/views.py +2 -2
@@ 26,8 26,8 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to, respond_no_content

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

from ..authorization.authorization import RolePermission


M byceps/blueprints/admin/user_badge/views.py => byceps/blueprints/admin/user_badge/views.py +2 -2
@@ 17,8 17,8 @@ from ....util.framework.flash import flash_success
from ....util.framework.templating import templated
from ....util.views import redirect_to

from ...authorization.decorators import permission_required
from ...authorization.registry import permission_registry
from ...common.authorization.decorators import permission_required
from ...common.authorization.registry import permission_registry

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

M byceps/blueprints/common/authentication/service.py => byceps/blueprints/common/authentication/service.py +2 -1
@@ 15,7 15,8 @@ from ....services.user import event_service as user_event_service
from ....typing import PartyID, UserID

from ...admin.core.authorization import AdminPermission
from ...authorization.registry import permission_registry

from ..authorization.registry import permission_registry

from . import session as user_session


R byceps/blueprints/authorization/__init__.py => byceps/blueprints/common/authorization/__init__.py +0 -0
R byceps/blueprints/authorization/decorators.py => byceps/blueprints/common/authorization/decorators.py +2 -2
@@ 1,6 1,6 @@
"""
byceps.blueprints.authorization.decorators
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
byceps.blueprints.common.authorization.decorators
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.

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

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.

R byceps/blueprints/authorization/views.py => byceps/blueprints/common/authorization/views.py +3 -3
@@ 1,12 1,12 @@
"""
byceps.blueprints.authorization.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
byceps.blueprints.common.authorization.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

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

from .registry import permission_registry


M byceps/blueprints/site/board/blueprint.py => byceps/blueprints/site/board/blueprint.py +1 -1
@@ 9,7 9,7 @@ byceps.blueprints.site.board.blueprint
from ....services.text_markup.service import render_html
from ....util.framework.blueprint import create_blueprint

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

from .authorization import (
    BoardPermission,

M byceps/blueprints/site/board/views_posting.py => byceps/blueprints/site/board/views_posting.py +1 -1
@@ 22,7 22,7 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import respond_no_content_with_location

from ...authorization.decorators import permission_required
from ...common.authorization.decorators import permission_required

from .authorization import BoardPermission, BoardPostingPermission
from .blueprint import blueprint

M byceps/blueprints/site/board/views_topic.py => byceps/blueprints/site/board/views_topic.py +1 -1
@@ 24,7 24,7 @@ from ....util.framework.flash import flash_error, flash_success
from ....util.framework.templating import templated
from ....util.views import respond_no_content_with_location

from ...authorization.decorators import permission_required
from ...common.authorization.decorators import permission_required

from .authorization import BoardPermission, BoardTopicPermission
from .blueprint import blueprint

M byceps/blueprints/site/news/views.py => byceps/blueprints/site/news/views.py +1 -1
@@ 20,7 20,7 @@ from ....util.framework.blueprint import create_blueprint
from ....util.framework.templating import templated

from ...admin.news.authorization import NewsItemPermission
from ...authorization.registry import permission_registry
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
@@ 27,7 27,7 @@ from ....util.views import respond_no_content

from ...admin.seating.authorization import SeatingPermission
from ...common.authentication.decorators import login_required
from ...authorization.registry import permission_registry
from ...common.authorization.registry import permission_registry

from . import service


M tests/unit/blueprints/authorization/test_registry.py => tests/unit/blueprints/authorization/test_registry.py +3 -1
@@ 8,7 8,9 @@ from unittest.mock import patch
import pytest

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