add docstrings to managemails.models
This commit is contained in:
parent
35eceb3307
commit
d78bad06b7
1 changed files with 32 additions and 0 deletions
|
@ -37,6 +37,16 @@ class MailboxManager(models.Manager):
|
|||
"""
|
||||
|
||||
def get_next_mailbox_name(self, osuser):
|
||||
"""
|
||||
Get the next available mailbox name for the given operating system
|
||||
user.
|
||||
|
||||
:param osuser: a :py:class:`operating system user <osuser.models.User>`
|
||||
instance
|
||||
:return: name of the mailbox
|
||||
:rtype: str
|
||||
|
||||
"""
|
||||
count = 1
|
||||
mailboxformat = "{0}p{1:02d}"
|
||||
mailboxname = mailboxformat.format(osuser.username, count)
|
||||
|
@ -54,6 +64,10 @@ class MailboxManager(models.Manager):
|
|||
|
||||
@python_2_unicode_compatible
|
||||
class Mailbox(ActivateAbleMixin, TimeStampedModel, models.Model):
|
||||
"""
|
||||
This is the model class for a mailbox.
|
||||
|
||||
"""
|
||||
osuser = models.ForeignKey(OsUser)
|
||||
username = models.CharField(max_length=128, unique=True)
|
||||
password = models.CharField(max_length=255)
|
||||
|
@ -66,6 +80,12 @@ class Mailbox(ActivateAbleMixin, TimeStampedModel, models.Model):
|
|||
verbose_name_plural = _('Mailboxes')
|
||||
|
||||
def set_password(self, password):
|
||||
"""
|
||||
Set the hashed password for the mailbox.
|
||||
|
||||
:param str password: the clear text password
|
||||
|
||||
"""
|
||||
self.password = sha512_crypt.encrypt(password)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
@ -82,6 +102,10 @@ class Mailbox(ActivateAbleMixin, TimeStampedModel, models.Model):
|
|||
|
||||
@python_2_unicode_compatible
|
||||
class MailAddress(ActivateAbleMixin, TimeStampedModel, models.Model):
|
||||
"""
|
||||
This is the model class for a mail address.
|
||||
|
||||
"""
|
||||
localpart = models.CharField(max_length=128)
|
||||
domain = models.ForeignKey(MailDomain)
|
||||
|
||||
|
@ -97,6 +121,10 @@ class MailAddress(ActivateAbleMixin, TimeStampedModel, models.Model):
|
|||
|
||||
@python_2_unicode_compatible
|
||||
class MailAddressMailbox(TimeStampedModel, models.Model):
|
||||
"""
|
||||
This is the model class to assign a mail address to a mailbox.
|
||||
|
||||
"""
|
||||
mailaddress = models.OneToOneField(MailAddress, primary_key=True)
|
||||
mailbox = models.ForeignKey(Mailbox)
|
||||
|
||||
|
@ -108,6 +136,10 @@ class MailAddressMailbox(TimeStampedModel, models.Model):
|
|||
|
||||
|
||||
class MailAddressForward(TimeStampedModel, models.Model):
|
||||
"""
|
||||
This is a model class to map mail addresses to forwarding addresses.
|
||||
|
||||
"""
|
||||
mailaddress = models.ForeignKey(MailAddress)
|
||||
target = models.EmailField(max_length=254)
|
||||
|
||||
|
|
Loading…
Reference in a new issue