Break circular dependencies introduced by importing common in verbs
This commit is contained in:
parent
9d966c2605
commit
161475baaa
5 changed files with 57 additions and 51 deletions
|
@ -5,7 +5,6 @@ import stripe
|
|||
|
||||
from app import billing
|
||||
from endpoints.api import request_error, log_action, NotFound
|
||||
from endpoints.common import check_repository_usage
|
||||
from data import model
|
||||
from data.billing import PLANS
|
||||
|
||||
|
@ -15,6 +14,20 @@ import features
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
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')
|
||||
|
||||
|
||||
def carderror_response(exc):
|
||||
return {'carderror': exc.message}, 402
|
||||
|
||||
|
|
Reference in a new issue