Skip to content

Commit

Permalink
Rename app mode "public" to "site"
Browse files Browse the repository at this point in the history
  • Loading branch information
homeworkprod committed Jun 28, 2020
1 parent 3cf5024 commit a71144c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions byceps/application.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion byceps/blueprints/authentication/views.py
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion byceps/blueprints/authorization/registry.py
Expand Up @@ -32,7 +32,7 @@ def get_enum_member(self, permission_id):
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:
Expand Down
4 changes: 2 additions & 2 deletions byceps/blueprints/core/views.py
Expand Up @@ -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
Expand Down
Expand Up @@ -21,7 +21,7 @@ <h1>{{ title }}</h1>
{%- 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 %}
Expand Down
2 changes: 1 addition & 1 deletion byceps/blueprints/user/current/views.py
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions byceps/config.py
Expand Up @@ -19,9 +19,9 @@
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):
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion config/development_party.py
Expand Up @@ -8,7 +8,7 @@

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

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

MAIL_DEBUG = True
Expand Down
2 changes: 1 addition & 1 deletion config/production_party.py
Expand Up @@ -15,7 +15,7 @@

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

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

MAIL_DEBUG = False
Expand Down
2 changes: 1 addition & 1 deletion config/test_party.py
Expand Up @@ -9,7 +9,7 @@

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

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

MAIL_DEBUG = False
Expand Down

0 comments on commit a71144c

Please sign in to comment.