call create/delete mailbox tasks when saving/deleting mailboxes
This commit is contained in:
parent
505b9c934b
commit
54b99281e3
3 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue