Add configurable limits for number of builds allowed under a namespace
We also support that limit being increased automatically once a successful billing charge has gone through
This commit is contained in:
parent
62971b7f20
commit
9a452ace11
10 changed files with 125 additions and 33 deletions
|
@ -80,7 +80,9 @@ def create_user_noverify(username, email, email_required=True, prompts=tuple()):
|
|||
|
||||
try:
|
||||
default_expr_s = _convert_to_s(config.app_config['DEFAULT_TAG_EXPIRATION'])
|
||||
new_user = User.create(username=username, email=email, removed_tag_expiration_s=default_expr_s)
|
||||
default_max_builds = config.app_config.get('DEFAULT_NAMESPACE_MAXIMUM_BUILD_COUNT')
|
||||
new_user = User.create(username=username, email=email, removed_tag_expiration_s=default_expr_s,
|
||||
maximum_queued_builds_count=default_max_builds)
|
||||
for prompt in prompts:
|
||||
create_user_prompt(new_user, prompt)
|
||||
|
||||
|
@ -88,6 +90,14 @@ def create_user_noverify(username, email, email_required=True, prompts=tuple()):
|
|||
except Exception as ex:
|
||||
raise DataModelException(ex.message)
|
||||
|
||||
def increase_maximum_build_count(user, maximum_queued_builds_count):
|
||||
""" Increases the maximum number of allowed builds on the namespace, if greater than that
|
||||
already present.
|
||||
"""
|
||||
if (user.maximum_queued_builds_count is not None and
|
||||
maximum_queued_builds_count > user.maximum_queued_builds_count):
|
||||
user.maximum_queued_builds_count = maximum_queued_builds_count
|
||||
user.save()
|
||||
|
||||
def is_username_unique(test_username):
|
||||
try:
|
||||
|
|
Reference in a new issue