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
|
@ -1,6 +1,7 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
* :feature:`-` call create/delete mailbox tasks when saving/deleting mailboxes
|
||||||
* :support:`-` use celery routers from gvacommon
|
* :support:`-` use celery routers from gvacommon
|
||||||
* :feature:`-` automatic creation of mailbox names from user names
|
* :feature:`-` automatic creation of mailbox names from user names
|
||||||
* :bug:`-` fix broken mailbox admin
|
* :bug:`-` fix broken mailbox admin
|
||||||
|
|
|
@ -7,6 +7,7 @@ from model_utils.models import TimeStampedModel
|
||||||
|
|
||||||
from domains.models import MailDomain
|
from domains.models import MailDomain
|
||||||
from osusers.models import User as OsUser
|
from osusers.models import User as OsUser
|
||||||
|
from osusers.tasks import create_file_mailbox, delete_file_mailbox
|
||||||
|
|
||||||
|
|
||||||
class ActivateAbleMixin(models.Model):
|
class ActivateAbleMixin(models.Model):
|
||||||
|
@ -53,6 +54,14 @@ class Mailbox(ActivateAbleMixin, TimeStampedModel, models.Model):
|
||||||
def set_password(self, password):
|
def set_password(self, password):
|
||||||
self.password = sha512_crypt.encrypt(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):
|
def __str__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
||||||
|
|
|
@ -51,3 +51,13 @@ def setup_file_mail_userdir(username):
|
||||||
@shared_task
|
@shared_task
|
||||||
def delete_file_mail_userdir(username):
|
def delete_file_mail_userdir(username):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@shared_task
|
||||||
|
def create_file_mailbox(username, mailboxname):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@shared_task
|
||||||
|
def delete_file_mailbox(username, mailboxname):
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in a new issue