mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -331,6 +331,16 @@ class AccountViewSetTestCase(ModoAPITestCase):
|
||||
resp = self.client.patch(url, data, format="json")
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
def test_update_quota(self):
|
||||
account = core_models.User.objects.get(username="user@test.com")
|
||||
url = reverse("v2:account-detail", args=[account.pk])
|
||||
data = {
|
||||
"mailbox": {"quota": 1},
|
||||
}
|
||||
resp = self.client.patch(url, data, format="json")
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertEqual(account.mailbox.quota, data["mailbox"]["quota"])
|
||||
|
||||
def test_user_updates_password(self):
|
||||
account = core_models.User.objects.get(username="user@test.com")
|
||||
self.authenticate_user(account)
|
||||
|
||||
@@ -295,19 +295,21 @@ class Mailbox(mixins.MessageLimitMixin, AdminObject):
|
||||
def update_from_dict(self, user, values):
|
||||
"""Update mailbox from a dictionary."""
|
||||
newaddress = None
|
||||
if values["email"] != self.full_address:
|
||||
newaddress = values["email"]
|
||||
elif (
|
||||
self.user.role == "SimpleUsers" and self.user.username != self.full_address
|
||||
):
|
||||
newaddress = self.user.username
|
||||
if newaddress is not None:
|
||||
local_part, domname = split_mailbox(newaddress)
|
||||
domain = Domain.objects.filter(name=domname).first()
|
||||
if domain is None:
|
||||
raise lib_exceptions.NotFound(_("Domain does not exist"))
|
||||
if not user.can_access(domain):
|
||||
raise lib_exceptions.PermDeniedException
|
||||
if "email" in values:
|
||||
if values["email"] != self.full_address:
|
||||
newaddress = values["email"]
|
||||
elif (
|
||||
self.user.role == "SimpleUsers"
|
||||
and self.user.username != self.full_address
|
||||
):
|
||||
newaddress = self.user.username
|
||||
if newaddress is not None:
|
||||
local_part, domname = split_mailbox(newaddress)
|
||||
domain = Domain.objects.filter(name=domname).first()
|
||||
if domain is None:
|
||||
raise lib_exceptions.NotFound(_("Domain does not exist"))
|
||||
if not user.can_access(domain):
|
||||
raise lib_exceptions.PermDeniedException
|
||||
if "use_domain_quota" in values:
|
||||
self.use_domain_quota = values["use_domain_quota"]
|
||||
if "use_domain_quota" in values or "quota" in values:
|
||||
|
||||
Reference in New Issue
Block a user