add inline editing for mail address targets
- move active flag into managemails.models.ActivateAbleMixin - refactor Mailbox and Mailaddress to use ActivateAbleMixin - implement managemails.models.Mailbox.__str__ - add managemails.admin.ActivationChangeMixin to provide activate and deactivate actions for model admin classes - add activate and deactivate actions for managemails.admin.MailboxAdmin - add managemails.admin.MailAddressAdmin and inlines for MailAddressMailbox and MailAddressForward management on the MailAddress management admin page
This commit is contained in:
parent
b044fe2dd9
commit
ee46a61e6d
2 changed files with 52 additions and 7 deletions
|
@ -16,13 +16,24 @@ class MailDomain(models.Model):
|
|||
return self.domain
|
||||
|
||||
|
||||
class Mailbox(models.Model):
|
||||
class ActivateAbleMixin(models.Model):
|
||||
"""
|
||||
Mixin for model classes that can be active or inactive.
|
||||
|
||||
"""
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Mailbox(ActivateAbleMixin, models.Model):
|
||||
username = models.CharField(max_length=128, unique=True)
|
||||
password = models.CharField(max_length=255)
|
||||
home = models.CharField(max_length=255)
|
||||
uid = models.PositiveSmallIntegerField()
|
||||
gid = models.PositiveSmallIntegerField()
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Mailbox')
|
||||
|
@ -31,12 +42,14 @@ class Mailbox(models.Model):
|
|||
def set_password(self, password):
|
||||
self.password = sha512_crypt.encrypt(password)
|
||||
|
||||
def __str__(self):
|
||||
return self.username
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MailAddress(models.Model):
|
||||
class MailAddress(ActivateAbleMixin, models.Model):
|
||||
localpart = models.CharField(max_length=128)
|
||||
domain = models.ForeignKey(MailDomain)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('localpart', 'domain')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue