add model features to hostingpackages
- add properties mailboxes, used_mailbox_count, mailbox_count and may_add_mailbox to CustomerHostingPackage class - use new properties in template dashboard/user_dashboard.html
This commit is contained in:
parent
8a84c9660a
commit
03e5c74d7a
2 changed files with 13 additions and 3 deletions
|
@ -272,7 +272,12 @@ class CustomerHostingPackage(HostingPackageBase):
|
||||||
hard = soft * 105 / 100
|
hard = soft * 105 / 100
|
||||||
return (soft, hard)
|
return (soft, hard)
|
||||||
|
|
||||||
def get_used_mailboxes(self):
|
def get_mailboxes(self):
|
||||||
|
if self.osuser:
|
||||||
|
return Mailbox.objects.filter(osuser=self.osuser).all()
|
||||||
|
mailboxes = property(get_mailboxes)
|
||||||
|
|
||||||
|
def get_used_mailbox_count(self):
|
||||||
"""
|
"""
|
||||||
Get the number of used mailboxes for this hosting package.
|
Get the number of used mailboxes for this hosting package.
|
||||||
|
|
||||||
|
@ -280,8 +285,9 @@ class CustomerHostingPackage(HostingPackageBase):
|
||||||
if self.osuser:
|
if self.osuser:
|
||||||
return Mailbox.objects.filter(osuser=self.osuser).count()
|
return Mailbox.objects.filter(osuser=self.osuser).count()
|
||||||
return 0
|
return 0
|
||||||
|
used_mailbox_count = property(get_used_mailbox_count)
|
||||||
|
|
||||||
def get_mailboxes(self):
|
def get_mailbox_count(self):
|
||||||
"""
|
"""
|
||||||
Get the number of mailboxes provided by this hosting package and all
|
Get the number of mailboxes provided by this hosting package and all
|
||||||
of its mailbox options.
|
of its mailbox options.
|
||||||
|
@ -293,6 +299,10 @@ class CustomerHostingPackage(HostingPackageBase):
|
||||||
mailbox_sum=models.Sum('number')
|
mailbox_sum=models.Sum('number')
|
||||||
)
|
)
|
||||||
return self.mailboxcount + (result['mailbox_sum'] or 0)
|
return self.mailboxcount + (result['mailbox_sum'] or 0)
|
||||||
|
mailbox_count = property(get_mailbox_count)
|
||||||
|
|
||||||
|
def may_add_mailbox(self):
|
||||||
|
return self.used_mailbox_count < self.mailbox_count
|
||||||
|
|
||||||
def get_databases(self):
|
def get_databases(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<span title="{% blocktrans %}The reserved disk space for your hosting package is {{ diskspace }} bytes.{% endblocktrans %}">{{ diskspace|filesizeformat }}</span>
|
<span title="{% blocktrans %}The reserved disk space for your hosting package is {{ diskspace }} bytes.{% endblocktrans %}">{{ diskspace|filesizeformat }}</span>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</th>
|
</th>
|
||||||
<th>{% blocktrans with num=package.get_used_mailboxes total=package.get_mailboxes %}used {{ num }} of {{ total }}{% endblocktrans %}</th>
|
<th>{% blocktrans with num=package.used_mailbox_count total=package.mailbox_count %}used {{ num }} of {{ total }}{% endblocktrans %}</th>
|
||||||
<th>{% for dbtype in package.get_databases %}
|
<th>{% for dbtype in package.get_databases %}
|
||||||
{{ dbtype.number }} {% include "userdbs/snippets/db_type.html" with db_type=dbtype.db_type %}
|
{{ dbtype.number }} {% include "userdbs/snippets/db_type.html" with db_type=dbtype.db_type %}
|
||||||
{% if not forloop.last %} / {% endif %}
|
{% if not forloop.last %} / {% endif %}
|
||||||
|
|
Loading…
Reference in a new issue