Refactor managemails to use signals
- use signals to trigger Celery tasks to create and delete mailboxes - add generic TestCaseWithCeleryTasks class to handle celery task tests in a uniform way
This commit is contained in:
parent
d6fc29a2b8
commit
610f8976fc
5 changed files with 114 additions and 37 deletions
|
@ -8,7 +8,6 @@ from model_utils.models import TimeStampedModel
|
|||
from passlib.handlers.sha2_crypt import sha512_crypt
|
||||
|
||||
from domains.models import MailDomain
|
||||
from fileservertasks.tasks import create_file_mailbox, delete_file_mailbox
|
||||
from osusers.models import User as OsUser
|
||||
|
||||
|
||||
|
@ -123,16 +122,6 @@ class Mailbox(ActivateAbleMixin, TimeStampedModel):
|
|||
"""
|
||||
self.password = sha512_crypt.hash(password)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# TODO: refactor to use signals
|
||||
create_file_mailbox.delay(self.osuser.username, self.username).get()
|
||||
super(Mailbox, self).save(*args, **kwargs)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
# TODO: refactor to use signals
|
||||
delete_file_mailbox.delay(self.osuser.username, self.username).get()
|
||||
super(Mailbox, self).delete(*args, **kwargs)
|
||||
|
||||
def get_mailaddresses(self):
|
||||
"""
|
||||
Get a list of mail addresses assigned to this mailbox.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue