diff --git a/docs/changelog.rst b/docs/changelog.rst index b1e5a45..2045692 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,7 @@ Changelog ========= +* :feature:`-` call create/delete mailbox tasks when saving/deleting mailboxes * :support:`-` use celery routers from gvacommon * :feature:`-` automatic creation of mailbox names from user names * :bug:`-` fix broken mailbox admin diff --git a/gnuviechadmin/managemails/models.py b/gnuviechadmin/managemails/models.py index 8ea4da0..737dda0 100644 --- a/gnuviechadmin/managemails/models.py +++ b/gnuviechadmin/managemails/models.py @@ -7,6 +7,7 @@ from model_utils.models import TimeStampedModel from domains.models import MailDomain from osusers.models import User as OsUser +from osusers.tasks import create_file_mailbox, delete_file_mailbox class ActivateAbleMixin(models.Model): @@ -53,6 +54,14 @@ class Mailbox(ActivateAbleMixin, TimeStampedModel, models.Model): def set_password(self, password): self.password = sha512_crypt.encrypt(password) + def save(self, *args, **kwargs): + create_file_mailbox.delay(self.osuser.username, self.username).get() + super(Mailbox, self).save(*args, **kwargs) + + def delete(self, *args, **kwargs): + delete_file_mailbox.delay(self.osuser.username, self.username).get() + super(Mailbox, self).delete(*args, **kwargs) + def __str__(self): return self.username diff --git a/gnuviechadmin/osusers/tasks.py b/gnuviechadmin/osusers/tasks.py index d1457b4..99c7b1c 100644 --- a/gnuviechadmin/osusers/tasks.py +++ b/gnuviechadmin/osusers/tasks.py @@ -51,3 +51,13 @@ def setup_file_mail_userdir(username): @shared_task def delete_file_mail_userdir(username): pass + + +@shared_task +def create_file_mailbox(username, mailboxname): + pass + + +@shared_task +def delete_file_mailbox(username, mailboxname): + pass