performance optimizations for hosting package detail view

- prefetch database objects in CustomerHostingPackageDetails.get_context_data
- use prefetched data in template hostingpackage/customerhostingpackage_detail.html
- mention optimization in changelog
This commit is contained in:
Jan Dittberner 2015-01-26 12:00:26 +01:00
parent 638a6f6712
commit f3168ffdb7
3 changed files with 19 additions and 12 deletions

View file

@ -1,6 +1,7 @@
Changelog
=========
* :support:`-` performance improvement for hosting package detail view
* :support:`-` move HostingPackageAndCustomerMixin from managemails.views to
gvawebcore.views

View file

@ -114,6 +114,12 @@ class CustomerHostingPackageDetails(StaffOrSelfLoginRequiredMixin, DetailView):
context.update({
'customer': self.get_customer_object(),
'uploadserver': settings.OSUSER_UPLOAD_SERVER,
'databases': context['hostingpackage'].databases,
'osuser': context['hostingpackage'].osuser,
'hostingoptions':
context['hostingpackage'].get_hostingoptions(),
'domains': context['hostingpackage'].domains.all(),
'mailboxes': context['hostingpackage'].mailboxes,
})
return context

View file

@ -38,8 +38,8 @@
<dt>{% trans "Mailboxes" %}</dt>
<dd>{% blocktrans with num=hostingpackage.used_mailbox_count total=hostingpackage.mailbox_count %}{{ num }} of {{ total }} in use{% endblocktrans %} <span class="glyphicon
glyphicon-info-sign" title="{% blocktrans with mailboxes=hostingpackage.mailboxcount %}The package provides {{ mailboxcount }} mailboxes the difference comes from mailbox options.{% endblocktrans %}"></span></dd>
<dt>{% if hostingpackage.osuser.is_sftp_user %}{% trans "SFTP username" %}{% else %}{% trans "SSH/SFTP username" %}{% endif %}</dt>
<dd>{{ hostingpackage.osuser.username }}</dd>
<dt>{% if osuser.is_sftp_user %}{% trans "SFTP username" %}{% else %}{% trans "SSH/SFTP username" %}{% endif %}</dt>
<dd>{{ osuser.username }}</dd>
<dt>{% trans "Upload server" %}</dt>
<dd>{{ uploadserver }}</dd>
</dl>
@ -48,9 +48,9 @@
<div class="col-lg-4 col-md-6 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">{% trans "Hosting Package Options" %}</div>
{% if hostingpackage.customerhostingpackageoption_set.exists %}
{% if hostingoptions %}
<ul class="list-group">
{% for opt in hostingpackage.get_hostingoptions %}
{% for opt in hostingoptions %}
<li class="list-group-item">{{ opt }}</li>
{% endfor %}
</ul>
@ -67,7 +67,7 @@
<div class="panel-heading">{% trans "Hosting Package Actions" %}</div>
<ul class="list-group">
<li class="list-group-item"><a href="#" title="{% trans "Edit Hosting Package Description" %}">{% trans "Edit description" %}</a></li>
<li class="list-group-item"><a href="{% url "set_osuser_password" slug=hostingpackage.osuser.username %}">{% if hostingpackage.osuser.is_sftp %}{% trans "Set SFTP password" %}{% else %}{% trans "Set SSH/SFTP password" %}{% endif %}</a></li>
<li class="list-group-item"><a href="{% url "set_osuser_password" slug=osuser.username %}">{% if osuser.is_sftp %}{% trans "Set SFTP password" %}{% else %}{% trans "Set SSH/SFTP password" %}{% endif %}</a></li>
</ul>
</div>
</div>
@ -76,7 +76,7 @@
<div class="col-lg-12 col-md-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">{% trans "Domains" %}</div>
{% if hostingpackage.domains %}
{% if domains %}
<table class="table table-condensed">
<thead>
<tr>
@ -87,7 +87,7 @@
</tr>
</thead>
<tbody>
{% for domain in hostingpackage.domains.all %}
{% for domain in domains %}
<tr>
<td>{{ domain.domain }}</td>
{% if domain.domain.maildomain %}
@ -126,7 +126,7 @@
<div class="col-lg-12 col-md-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">{% trans "E-Mail-Accounts" %}</div>
{% if hostingpackage.mailboxes %}
{% if mailboxes %}
<table class="table table-condensed">
<thead>
<tr>
@ -137,7 +137,7 @@
</tr>
</thead>
<tbody>
{% for mailbox in hostingpackage.mailboxes %}
{% for mailbox in mailboxes %}
<tr>
<td>{{ mailbox.username }}</td>
<td>{{ mailbox.mailaddresses|join:", " }}</td>
@ -161,7 +161,7 @@
<div class="col-lg-12 col-md-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">{% trans "Databases" %}</div>
{% if hostingpackage.databases %}
{% if databases %}
<table class="table table-condensed">
<thead>
<tr>
@ -172,11 +172,11 @@
</tr>
</thead>
<tbody>
{% for database in hostingpackage.databases %}
{% for database in databases %}
<tr>
<td>{% include "userdbs/snippets/db_type.html" with db_type=database.db_user.db_type %}</td>
<td>{{ database.db_name }}</td>
<td>{{ database.db_user.username }}</td>
<td>{{ database.db_user.name }}</td>
<td></td>
</tr>
{% endfor %}