Break circular dependencies introduced by importing common in verbs

This commit is contained in:
Joseph Schorr 2016-01-08 13:53:27 -05:00
parent 9d966c2605
commit 161475baaa
5 changed files with 57 additions and 51 deletions

View file

@ -14,12 +14,10 @@ from flask.ext.principal import identity_changed
from random import SystemRandom
from cachetools import lru_cache
from data import model
from app import app, oauth_apps, LoginWrappedDBUser
from auth.permissions import QuayDeferredPermissionUser
from auth import scopes
from endpoints.api.discovery import swagger_route_data
from werkzeug.routing import BaseConverter
from functools import wraps
from config import frontend_visible_config
@ -79,15 +77,6 @@ def route_hide_if(value):
return decorator
def get_route_data():
global route_data
if route_data:
return route_data
route_data = swagger_route_data(include_internal=True, compact=True)
return route_data
def truthy_param(param):
return param not in {False, 'false', 'False', '0', 'FALSE', '', 'null'}
@ -139,7 +128,7 @@ def _get_version_number():
except IOError:
return ''
def render_page_template(name, **kwargs):
def render_page_template(name, route_data=None, **kwargs):
debugging = app.config.get('DEBUGGING', False)
if debugging:
# If DEBUGGING is enabled, then we load the full set of individual JS and CSS files
@ -187,7 +176,7 @@ def render_page_template(name, **kwargs):
version_number = ' - ' + _get_version_number()
resp = make_response(render_template(name,
route_data=json.dumps(get_route_data()),
route_data=json.dumps(route_data),
external_styles=external_styles,
external_scripts=external_scripts,
main_styles=add_cachebusters(main_styles),
@ -214,17 +203,3 @@ def render_page_template(name, **kwargs):
resp.headers['X-FRAME-OPTIONS'] = 'DENY'
return resp
def check_repository_usage(user_or_org, plan_found):
private_repos = model.user.get_private_repo_count(user_or_org.username)
if plan_found is None:
repos_allowed = 0
else:
repos_allowed = plan_found['privateRepos']
if private_repos > repos_allowed:
model.notification.create_unique_notification('over_private_usage', user_or_org,
{'namespace': user_or_org.username})
else:
model.notification.delete_notifications_by_kind(user_or_org, 'over_private_usage')