Apply consistent Python and Django coding standards
This commit is contained in:
1 parent
1d0b5adeee
commit
d7314fa927
61 files changed
+1829
-603
No files matched your search
@@ -12,7 +12,7 @@ def lock_hosting_account(account_id, customer_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.
|
||||
# Lock writes before reading the account and resource counts.
|
||||
accounts.update(hosting_plan=F("hosting_plan"))
|
||||
return accounts.select_for_update().get()
|
||||
|
||||
@@ -32,7 +32,9 @@ def create_database_request(account_id, suffix, *, customer_id=None):
|
||||
and plan.database_limit is not None
|
||||
and databases.count() >= plan.database_limit
|
||||
):
|
||||
raise ValidationError("This hosting account has reached its database limit.")
|
||||
raise ValidationError(
|
||||
"This hosting account has reached its database limit."
|
||||
)
|
||||
return databases.create(suffix=suffix)
|
||||
|
||||
|
||||
@@ -48,7 +50,9 @@ def create_mailbox_request(account_id, local_part, *, customer_id=None):
|
||||
domain=spec.domain, defaults={"account": account}
|
||||
)
|
||||
if mail_domain.account_id != account.pk:
|
||||
raise ValidationError("This mail domain belongs to another hosting account.")
|
||||
raise ValidationError(
|
||||
"This mail domain belongs to another hosting account."
|
||||
)
|
||||
if mail_domain.mailboxes.filter(local_part=spec.local_part).exists():
|
||||
raise ValidationError(
|
||||
{"local_part": "This mailbox has already been requested."}
|
||||
@@ -58,5 +62,7 @@ def create_mailbox_request(account_id, local_part, *, customer_id=None):
|
||||
if plan and plan.mailbox_limit is not None:
|
||||
mailboxes = HostingMailbox.objects.filter(mail_domain__account=account)
|
||||
if mailboxes.count() >= plan.mailbox_limit:
|
||||
raise ValidationError("This hosting account has reached its mailbox limit.")
|
||||
raise ValidationError(
|
||||
"This hosting account has reached its mailbox limit."
|
||||
)
|
||||
return mail_domain.mailboxes.create(local_part=spec.local_part)
|
||||
Reference in new issue
Block a user