Allow customers to request databases and mailboxes within plan quotas
This commit is contained in:
1 parent
cba291d4a9
commit
1424206903
6 files changed
+114
-40
No files matched your search
@@ -7,8 +7,10 @@ from coulobre.mail_node import MailboxSpec
|
||||
from .models import HostingAccount, HostingMailbox, HostingMailDomain
|
||||
|
||||
|
||||
def lock_hosting_account(account_id):
|
||||
def lock_hosting_account(account_id, customer_id):
|
||||
accounts = HostingAccount.objects.filter(pk=account_id)
|
||||
if customer_id is not None:
|
||||
accounts = accounts.filter(customer_id=customer_id)
|
||||
if connection.vendor == "sqlite":
|
||||
# Acquire the write lock before reading the account and resource counts.
|
||||
accounts.update(hosting_plan=F("hosting_plan"))
|
||||
@@ -16,8 +18,8 @@ def lock_hosting_account(account_id):
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def create_database_request(account_id, suffix):
|
||||
account = lock_hosting_account(account_id)
|
||||
def create_database_request(account_id, suffix, *, customer_id=None):
|
||||
account = lock_hosting_account(account_id, customer_id)
|
||||
databases = account.databases
|
||||
if databases.filter(suffix=suffix).exists():
|
||||
raise ValidationError(
|
||||
@@ -35,8 +37,8 @@ def create_database_request(account_id, suffix):
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def create_mailbox_request(account_id, local_part):
|
||||
account = lock_hosting_account(account_id)
|
||||
def create_mailbox_request(account_id, local_part, *, customer_id=None):
|
||||
account = lock_hosting_account(account_id, customer_id)
|
||||
try:
|
||||
spec = MailboxSpec(account.primary_domain, local_part)
|
||||
except ValueError as error:
|
||||
|
||||
Reference in new issue
Block a user