Small formatting improvements to common
This commit is contained in:
parent
5d69fc2aa3
commit
41ac9019c6
1 changed files with 38 additions and 37 deletions
|
@ -2,9 +2,7 @@ import logging
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from functools import wraps
|
from flask import make_response, render_template, request, session
|
||||||
|
|
||||||
from flask import make_response, render_template, request, abort, session
|
|
||||||
from flask_login import login_user
|
from flask_login import login_user
|
||||||
from flask_principal import identity_changed
|
from flask_principal import identity_changed
|
||||||
|
|
||||||
|
@ -26,6 +24,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def common_login(db_user, permanent_session=True):
|
def common_login(db_user, permanent_session=True):
|
||||||
|
""" Performs login of the given user, with optional non-permanence on the session. """
|
||||||
if login_user(LoginWrappedDBUser(db_user.uuid, db_user)):
|
if login_user(LoginWrappedDBUser(db_user.uuid, db_user)):
|
||||||
logger.debug('Successfully signed in as: %s (%s)' % (db_user.username, db_user.uuid))
|
logger.debug('Successfully signed in as: %s (%s)' % (db_user.username, db_user.uuid))
|
||||||
new_identity = QuayDeferredPermissionUser.for_user(db_user)
|
new_identity = QuayDeferredPermissionUser.for_user(db_user)
|
||||||
|
@ -63,10 +62,11 @@ def _list_files(path, extension):
|
||||||
return os.path.join(dp, f)[len('static/'):]
|
return os.path.join(dp, f)[len('static/'):]
|
||||||
|
|
||||||
filepath = os.path.join('static/', path)
|
filepath = os.path.join('static/', path)
|
||||||
return [join_path(dp, f) for dp, dn, files in os.walk(filepath) for f in files if matches(f)]
|
return [join_path(dp, f) for dp, _, files in os.walk(filepath) for f in files if matches(f)]
|
||||||
|
|
||||||
|
|
||||||
def render_page_template(name, route_data=None, **kwargs):
|
def render_page_template(name, route_data=None, **kwargs):
|
||||||
|
""" Renders the page template with the given name as the response and returns its contents. """
|
||||||
library_styles = []
|
library_styles = []
|
||||||
main_styles = []
|
main_styles = []
|
||||||
library_scripts = []
|
library_scripts = []
|
||||||
|
@ -110,39 +110,40 @@ def render_page_template(name, route_data=None, **kwargs):
|
||||||
if not features.BILLING:
|
if not features.BILLING:
|
||||||
version_number = 'Quay %s' % __version__
|
version_number = 'Quay %s' % __version__
|
||||||
|
|
||||||
resp = make_response(render_template(name,
|
contents = render_template(name,
|
||||||
route_data=route_data,
|
route_data=route_data,
|
||||||
external_styles=external_styles,
|
external_styles=external_styles,
|
||||||
external_scripts=external_scripts,
|
external_scripts=external_scripts,
|
||||||
main_styles=main_styles,
|
main_styles=main_styles,
|
||||||
library_styles=library_styles,
|
library_styles=library_styles,
|
||||||
main_scripts=main_scripts,
|
main_scripts=main_scripts,
|
||||||
library_scripts=library_scripts,
|
library_scripts=library_scripts,
|
||||||
feature_set=features.get_features(),
|
feature_set=features.get_features(),
|
||||||
config_set=frontend_visible_config(app.config),
|
config_set=frontend_visible_config(app.config),
|
||||||
oauth_set=get_oauth_config(),
|
oauth_set=get_oauth_config(),
|
||||||
external_login_set=get_external_login_config(),
|
external_login_set=get_external_login_config(),
|
||||||
scope_set=scopes.app_scopes(app.config),
|
scope_set=scopes.app_scopes(app.config),
|
||||||
vuln_priority_set=PRIORITY_LEVELS,
|
vuln_priority_set=PRIORITY_LEVELS,
|
||||||
enterprise_logo=app.config.get('ENTERPRISE_LOGO_URL', ''),
|
enterprise_logo=app.config.get('ENTERPRISE_LOGO_URL', ''),
|
||||||
mixpanel_key=app.config.get('MIXPANEL_KEY', ''),
|
mixpanel_key=app.config.get('MIXPANEL_KEY', ''),
|
||||||
munchkin_key=app.config.get('MARKETO_MUNCHKIN_ID', ''),
|
munchkin_key=app.config.get('MARKETO_MUNCHKIN_ID', ''),
|
||||||
recaptcha_key=app.config.get('RECAPTCHA_SITE_KEY', ''),
|
recaptcha_key=app.config.get('RECAPTCHA_SITE_KEY', ''),
|
||||||
google_tagmanager_key=app.config.get('GOOGLE_TAGMANAGER_KEY', ''),
|
google_tagmanager_key=app.config.get('GOOGLE_TAGMANAGER_KEY', ''),
|
||||||
google_anaytics_key=app.config.get('GOOGLE_ANALYTICS_KEY', ''),
|
google_anaytics_key=app.config.get('GOOGLE_ANALYTICS_KEY', ''),
|
||||||
sentry_public_dsn=app.config.get('SENTRY_PUBLIC_DSN', ''),
|
sentry_public_dsn=app.config.get('SENTRY_PUBLIC_DSN', ''),
|
||||||
is_debug=str(app.config.get('DEBUGGING', False)).lower(),
|
is_debug=str(app.config.get('DEBUGGING', False)).lower(),
|
||||||
show_chat=features.SUPPORT_CHAT,
|
show_chat=features.SUPPORT_CHAT,
|
||||||
aci_conversion=features.ACI_CONVERSION,
|
aci_conversion=features.ACI_CONVERSION,
|
||||||
has_billing=features.BILLING,
|
has_billing=features.BILLING,
|
||||||
contact_href=contact_href,
|
contact_href=contact_href,
|
||||||
hostname=app.config['SERVER_HOSTNAME'],
|
hostname=app.config['SERVER_HOSTNAME'],
|
||||||
preferred_scheme=app.config['PREFERRED_URL_SCHEME'],
|
preferred_scheme=app.config['PREFERRED_URL_SCHEME'],
|
||||||
version_number=version_number,
|
version_number=version_number,
|
||||||
license_insufficient=license_validator.insufficient,
|
license_insufficient=license_validator.insufficient,
|
||||||
license_expiring=license_validator.expiring_soon,
|
license_expiring=license_validator.expiring_soon,
|
||||||
current_year=datetime.datetime.now().year,
|
current_year=datetime.datetime.now().year,
|
||||||
**kwargs))
|
**kwargs)
|
||||||
|
|
||||||
|
resp = make_response(contents)
|
||||||
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
|
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
|
||||||
return resp
|
return resp
|
||||||
|
|
Reference in a new issue