Add UI for handling the case when an enterprise has reached its maximum seat count
This commit is contained in:
parent
22cc7a85d4
commit
205362bc7b
7 changed files with 47 additions and 4 deletions
|
@ -66,6 +66,10 @@ class Unauthorized(ApiException):
|
|||
ApiException.__init__(self, 'insufficient_scope', 403, 'Unauthorized', payload)
|
||||
|
||||
|
||||
class ExceedsLicenseException(ApiException):
|
||||
def __init__(self, payload=None):
|
||||
ApiException.__init__(self, None, 402, 'Payment Required', payload)
|
||||
|
||||
|
||||
class NotFound(ApiException):
|
||||
def __init__(self, payload=None):
|
||||
|
@ -275,6 +279,10 @@ def request_error(exception=None, **kwargs):
|
|||
raise InvalidRequest(message, data)
|
||||
|
||||
|
||||
def license_error(exception=None):
|
||||
raise ExceedsLicenseException()
|
||||
|
||||
|
||||
def log_action(kind, user_or_orgname, metadata=None, repo=None):
|
||||
if not metadata:
|
||||
metadata = {}
|
||||
|
|
|
@ -8,7 +8,7 @@ from flask.ext.principal import identity_changed, AnonymousIdentity
|
|||
from app import app, billing as stripe, authentication
|
||||
from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error,
|
||||
log_action, internal_only, NotFound, require_user_admin,
|
||||
InvalidToken, require_scope, format_date, hide_if, show_if)
|
||||
InvalidToken, require_scope, format_date, hide_if, show_if, license_error)
|
||||
from endpoints.api.subscribe import subscribe
|
||||
from endpoints.common import common_login
|
||||
from data import model
|
||||
|
@ -193,6 +193,8 @@ class User(ApiResource):
|
|||
code = model.create_confirm_email_code(new_user)
|
||||
send_confirmation_email(new_user.username, new_user.email, code.code)
|
||||
return 'Created', 201
|
||||
except model.TooManyUsersException as ex:
|
||||
raise license_error(exception=ex)
|
||||
except model.DataModelException as ex:
|
||||
raise request_error(exception=ex)
|
||||
|
||||
|
|
Reference in a new issue