implement adding options to hosting packages
- fix unique constraints on CustomerDiskSpaceOption and CustomerUserDatabaseOption to allow multiple options from the same template for hosting packages - fix disk space calculation in CustomerHostingPackage - implement hostingpackages forms AddDiskspaceOptionForm, AddMailboxOptionForm, AddUserDatabaseOptionForm - implement hostingpackages.views.AddHostingOption - add new URL pattern add_hosting_option to hostingpackages.urls - add template hostingpackages/add_hosting_option.html - link items on hostingpackages/customerhostingpackage_option_choices.html to add_hosting_option
This commit is contained in:
parent
9815bd1f5b
commit
0fc823a305
8 changed files with 229 additions and 14 deletions
|
@ -80,7 +80,6 @@ class DiskSpaceOptionBase(models.Model):
|
|||
class Meta:
|
||||
abstract = True
|
||||
ordering = ['diskspace_unit', 'diskspace']
|
||||
unique_together = ['diskspace', 'diskspace_unit']
|
||||
verbose_name = _('Disk space option')
|
||||
verbose_name_plural = _('Disk space options')
|
||||
|
||||
|
@ -95,6 +94,8 @@ class DiskSpaceOption(DiskSpaceOptionBase, HostingOption):
|
|||
existing hosting packages.
|
||||
|
||||
"""
|
||||
class Meta:
|
||||
unique_together = ['diskspace', 'diskspace_unit']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
@ -107,7 +108,6 @@ class UserDatabaseOptionBase(models.Model):
|
|||
class Meta:
|
||||
abstract = True
|
||||
ordering = ['db_type', 'number']
|
||||
unique_together = ['number', 'db_type']
|
||||
verbose_name = _('Database option')
|
||||
verbose_name_plural = _('Database options')
|
||||
|
||||
|
@ -127,6 +127,8 @@ class UserDatabaseOption(UserDatabaseOptionBase, HostingOption):
|
|||
hosting packages.
|
||||
|
||||
"""
|
||||
class Meta:
|
||||
unique_together = ['number', 'db_type']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
@ -267,7 +269,7 @@ class CustomerHostingPackage(HostingPackageBase):
|
|||
options = CustomerDiskSpaceOption.objects.filter(hosting_package=self)
|
||||
for option in options:
|
||||
if option.diskspace_unit == min_unit:
|
||||
diskspace += option.disk_space
|
||||
diskspace += option.diskspace
|
||||
elif option.diskspace_unit > min_unit:
|
||||
diskspace += (
|
||||
DISK_SPACE_FACTORS[option.diskspace_unit][min_unit] *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue