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
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import django.utils.timezone
|
||||
import model_utils.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('domains', '0002_auto_20150124_1909'),
|
||||
('hostingpackages', '0003_auto_20150118_1407'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='CustomerHostingPackageDomain',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
|
||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
|
||||
('domain', models.OneToOneField(verbose_name='hosting domain', to='domains.HostingDomain')),
|
||||
('hosting_package', models.ForeignKey(related_name='domains', verbose_name='hosting package', to='hostingpackages.CustomerHostingPackage')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
|
@ -14,6 +14,7 @@ from django.utils.translation import ugettext_lazy as _, ungettext
|
|||
from model_utils import Choices
|
||||
from model_utils.models import TimeStampedModel
|
||||
|
||||
from domains.models import HostingDomain
|
||||
from managemails.models import Mailbox
|
||||
from osusers.models import (
|
||||
AdditionalGroup,
|
||||
|
@ -66,6 +67,7 @@ class HostingOption(TimeStampedModel):
|
|||
|
||||
"""
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DiskSpaceOptionBase(models.Model):
|
||||
diskspace = models.PositiveIntegerField(_('disk space'))
|
||||
|
@ -83,6 +85,7 @@ class DiskSpaceOptionBase(models.Model):
|
|||
return _("Additional disk space {space} {unit}").format(
|
||||
space=self.diskspace, unit=self.get_diskspace_unit_display())
|
||||
|
||||
|
||||
class DiskSpaceOption(DiskSpaceOptionBase, HostingOption):
|
||||
"""
|
||||
This is a class for hosting options adding additional disk space to
|
||||
|
@ -329,6 +332,30 @@ class CustomerHostingPackage(HostingPackageBase):
|
|||
return super(CustomerHostingPackage, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CustomerHostingPackageDomain(TimeStampedModel):
|
||||
"""
|
||||
This class defines the relationship from a hosting package to a hosting
|
||||
domain.
|
||||
|
||||
"""
|
||||
hosting_package = models.ForeignKey(
|
||||
CustomerHostingPackage, verbose_name=_('hosting package'),
|
||||
related_name='domains')
|
||||
domain = models.OneToOneField(
|
||||
HostingDomain, verbose_name=_('hosting domain'))
|
||||
|
||||
def __str__(self):
|
||||
return self.domain.domain
|
||||
|
||||
def is_usable_for_email(self):
|
||||
"""
|
||||
Tells wether the related domain is usable for email addresses.
|
||||
|
||||
"""
|
||||
return self.domain.maildomain is not None
|
||||
|
||||
|
||||
class CustomerHostingPackageOption(TimeStampedModel):
|
||||
"""
|
||||
This class defines options for customer hosting packages.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue