Add a check_repository_usage method which adds (or removes) a notification on the user/org when they go over their plan usage
This commit is contained in:
parent
525ef8d14f
commit
e5a461989f
6 changed files with 39 additions and 28 deletions
|
@ -126,11 +126,14 @@ def render_page_template(name, **kwargs):
|
|||
return resp
|
||||
|
||||
|
||||
def add_notification(kind, metadata=None, user=None):
|
||||
if not user and current_user:
|
||||
user = current_user.db_user()
|
||||
def check_repository_usage(user_or_org, plan_found):
|
||||
private_repos = model.get_private_repo_count(user_or_org.username)
|
||||
repos_allowed = plan_found['privateRepos']
|
||||
|
||||
return model.create_notification(kind, user, metadata or {})
|
||||
if private_repos > repos_allowed:
|
||||
model.create_notification('over_private_usage', user_or_org, {'namespace': user_or_org.username})
|
||||
else:
|
||||
model.delete_notifications_by_kind(user_or_org, 'over_private_usage')
|
||||
|
||||
|
||||
def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
|
||||
|
|
Reference in a new issue