Skip to content

Commit

Permalink
πŸ§‘β€πŸ’»(domains) change default ordering
Browse files Browse the repository at this point in the history
Order by last created models MailDomain, Mailbox and MailDomainAccess.
  • Loading branch information
sdemagny committed Feb 12, 2025
1 parent fbb4797 commit e554688
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/backend/mailbox_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Meta:
db_table = "people_mail_domain"
verbose_name = _("Mail domain")
verbose_name_plural = _("Mail domains")
ordering = ["-created_at"]

def __str__(self):
return self.name
Expand Down Expand Up @@ -109,6 +110,7 @@ class Meta:
verbose_name = _("User/mail domain relation")
verbose_name_plural = _("User/mail domain relations")
unique_together = ("user", "domain")
ordering = ["-created_at"]

def __str__(self):
return f"Access of user {self.user} on domain {self.domain}."
Expand Down Expand Up @@ -206,6 +208,7 @@ class Meta:
verbose_name = _("Mailbox")
verbose_name_plural = _("Mailboxes")
unique_together = ("local_part", "domain")
ordering = ["-created_at"]

def __str__(self):
return f"{self.local_part!s}@{self.domain.name:s}"
Expand Down
4 changes: 2 additions & 2 deletions src/backend/mailbox_manager/tests/test_utils_dimail_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ def test_dimail__enable_pending_mailboxes(caplog):
)
assert (
caplog.records[2].message
== f"Information for mailbox mock@{domain.name} sent to {mailbox1.secondary_email}."
== f"Information for mailbox mock@{domain.name} sent to {mailbox2.secondary_email}."
)
assert (
caplog.records[4].message
== f"Mailbox successfully created on domain {domain.name} by user None"
)
assert (
caplog.records[5].message
== f"Information for mailbox mock@{domain.name} sent to {mailbox2.secondary_email}."
== f"Information for mailbox mock@{domain.name} sent to {mailbox1.secondary_email}."
)

0 comments on commit e554688

Please sign in to comment.