~homeworkprod/byceps

a71144c810996ecf22a62dc943115487201b8b8f — Jochen Kupperschmidt 1 year, 3 months ago 3cf5024
Rename app mode "public" to "site"
M byceps/application.py => byceps/application.py +2 -2
@@ 80,7 80,7 @@ def _get_blueprints(app: Flask) -> Iterator[BlueprintReg]:
    yield from _get_blueprints_common()

    current_mode = config.get_app_mode(app)
    if current_mode.is_public():
    if current_mode.is_site():
        yield from _get_blueprints_site()
    elif current_mode.is_admin():
        yield from _get_blueprints_admin()


@@ 213,7 213,7 @@ def init_app(app: Flask) -> None:
        _set_url_root_path(app)

        app_mode = config.get_app_mode()
        if app_mode.is_public():
        if app_mode.is_site():
            # Incorporate site-specific template overrides.
            app.jinja_loader = SiteTemplateOverridesLoader()


M byceps/blueprints/authentication/views.py => byceps/blueprints/authentication/views.py +1 -1
@@ 271,7 271,7 @@ def request_password_reset():


def _get_sender() -> Optional[Sender]:
    if not get_app_mode().is_public():
    if not get_app_mode().is_site():
        return None

    site = site_service.get_site(g.site_id)

M byceps/blueprints/authorization/registry.py => byceps/blueprints/authorization/registry.py +1 -1
@@ 32,7 32,7 @@ class PermissionRegistry:
        if enum is None:
            # No enum found for that key. This happens if the blueprint
            # which contains the authorization enum is not registered in
            # the current app mode (public/admin).
            # the current app mode (admin/site).
            return None

        try:

M byceps/blueprints/core/views.py => byceps/blueprints/core/views.py +2 -2
@@ 80,13 80,13 @@ def provide_app_mode():
    g.app_mode = app_mode

    # site ID
    if app_mode.is_public():
    if app_mode.is_site():
        site_id = config.get_current_site_id()
        g.site_id = site_id

    # current party and brand
    party_id = None
    if app_mode.is_public():
    if app_mode.is_site():
        site = site_service.get_site(site_id)

        party_id = site.party_id

M byceps/blueprints/user/current/templates/user/current/view.html => byceps/blueprints/user/current/templates/user/current/view.html +1 -1
@@ 21,7 21,7 @@
  {%- with label_column_width = '8rem', data_column_min_width = '12rem' %}
{%- include 'user/current/_account.html' %}
{%- include 'user/current/_details_personal.html' %}
    {%- if g.app_mode.is_public() and newsletter_offered %}
    {%- if g.app_mode.is_site() and newsletter_offered %}
{%- include 'user/current/_newsletter.html' %}
    {%- endif %}
  {%- endwith %}

M byceps/blueprints/user/current/views.py => byceps/blueprints/user/current/views.py +1 -1
@@ 40,7 40,7 @@ def view():
    if user is None:
        abort(404)

    if get_app_mode().is_public():
    if get_app_mode().is_site():
        newsletter_list_id = _find_newsletter_list_for_brand()
        newsletter_offered = (newsletter_list_id is not None)


M byceps/config.py => byceps/config.py +3 -3
@@ 19,9 19,9 @@ KEY_APP_MODE = 'app_mode'
KEY_SITE_ID = 'site_id'


AppMode = Enum('AppMode', ['public', 'admin'])
AppMode = Enum('AppMode', ['admin', 'site'])
AppMode.is_admin = lambda self: self == AppMode.admin
AppMode.is_public = lambda self: self == AppMode.public
AppMode.is_site = lambda self: self == AppMode.site


class ConfigurationError(Exception):


@@ 34,7 34,7 @@ def init_app(app: Flask) -> None:
    app_mode = _determine_app_mode(app)
    set_extension_value(KEY_APP_MODE, app_mode, app)

    if app_mode.is_public():
    if app_mode.is_site():
        site_id = _determine_site_id(app)
        set_extension_value(KEY_SITE_ID, site_id, app)


M config/development_party.py => config/development_party.py +1 -1
@@ 8,7 8,7 @@ SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://byceps:boioioing@127.0.0.1/byce

REDIS_URL = 'redis://127.0.0.1:6379/0'

APP_MODE = 'public'
APP_MODE = 'site'
SITE_ID = 'example-dev'

MAIL_DEBUG = True

M config/production_party.py => config/production_party.py +1 -1
@@ 15,7 15,7 @@ SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://byceps:boioioing@127.0.0.1/byce

REDIS_URL = 'unix:///var/run/redis/redis.sock?db=0'

APP_MODE = 'public'
APP_MODE = 'site'
SITE_ID = 'example-prod'

MAIL_DEBUG = False

M config/test_party.py => config/test_party.py +1 -1
@@ 9,7 9,7 @@ SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://byceps_test:test@127.0.0.1/byce

REDIS_URL = 'redis://127.0.0.1:6379/0'

APP_MODE = 'public'
APP_MODE = 'site'
SITE_ID = 'acmecon-2014-website'

MAIL_DEBUG = False