implement model changes
- add new domains.apps.AppConfig to allow translatable app description for domains app - link domains to a customer - extract common functionality from domains.models.MailDomain into abstract domains.models.DomainBase - add separate domains.models.HostingDomain to allow for generic external domains - add new hostingpackages.models.CustomerHostingPackageDomain to assign hosting domains to hosting packages
This commit is contained in:
parent
a3e3e2a76f
commit
0c291f0510
6 changed files with 177 additions and 2 deletions
|
@ -1,4 +1,11 @@
|
|||
"""
|
||||
This module contains models related to domain names.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
@ -6,12 +13,54 @@ from model_utils.models import TimeStampedModel
|
|||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MailDomain(TimeStampedModel, models.Model):
|
||||
domain = models.CharField(max_length=128, unique=True)
|
||||
class DomainBase(TimeStampedModel):
|
||||
"""
|
||||
This is the base model for domains.
|
||||
|
||||
"""
|
||||
domain = models.CharField(_('domain name'), max_length=128, unique=True)
|
||||
customer = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, verbose_name=_('customer'), blank=True,
|
||||
null=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MailDomain(DomainBase):
|
||||
"""
|
||||
This is the model for mail domains. Mail domains are used to configure the
|
||||
mail servers (SMTP/IMAP/POP3). Mail addresses are assigned to these mail
|
||||
domains.
|
||||
|
||||
"""
|
||||
class Meta:
|
||||
verbose_name = _('Mail domain')
|
||||
verbose_name_plural = _('Mail domains')
|
||||
|
||||
def __str__(self):
|
||||
return self.domain
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class HostingDomain(DomainBase):
|
||||
"""
|
||||
This is the model for hosting domains. A hosting domain is linked to a
|
||||
customer hosting account.
|
||||
|
||||
"""
|
||||
maildomain = models.OneToOneField(
|
||||
MailDomain, verbose_name=_('mail domain'), blank=True, null=True,
|
||||
help_text=_('assigned mail domain for this domain')
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Hosting domain')
|
||||
verbose_name_plural = _('Hosting domains')
|
||||
|
||||
def __str__(self):
|
||||
return self.domain
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue