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 Changelog
========= =========
* :support:`-` performance improvement for hosting package detail view
* :support:`-` move HostingPackageAndCustomerMixin from managemails.views to * :support:`-` move HostingPackageAndCustomerMixin from managemails.views to
gvawebcore.views gvawebcore.views

View file

@ -114,6 +114,12 @@ class CustomerHostingPackageDetails(StaffOrSelfLoginRequiredMixin, DetailView):
context.update({ context.update({
'customer': self.get_customer_object(), 'customer': self.get_customer_object(),
'uploadserver': settings.OSUSER_UPLOAD_SERVER, '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 return context

View file

@ -38,8 +38,8 @@
<dt>{% trans "Mailboxes" %}</dt> <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 <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> 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> <dt>{% if osuser.is_sftp_user %}{% trans "SFTP username" %}{% else %}{% trans "SSH/SFTP username" %}{% endif %}</dt>
<dd>{{ hostingpackage.osuser.username }}</dd> <dd>{{ osuser.username }}</dd>
<dt>{% trans "Upload server" %}</dt> <dt>{% trans "Upload server" %}</dt>
<dd>{{ uploadserver }}</dd> <dd>{{ uploadserver }}</dd>
</dl> </dl>
@ -48,9 +48,9 @@
<div class="col-lg-4 col-md-6 col-xs-12"> <div class="col-lg-4 col-md-6 col-xs-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">{% trans "Hosting Package Options" %}</div> <div class="panel-heading">{% trans "Hosting Package Options" %}</div>
{% if hostingpackage.customerhostingpackageoption_set.exists %} {% if hostingoptions %}
<ul class="list-group"> <ul class="list-group">
{% for opt in hostingpackage.get_hostingoptions %} {% for opt in hostingoptions %}
<li class="list-group-item">{{ opt }}</li> <li class="list-group-item">{{ opt }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -67,7 +67,7 @@
<div class="panel-heading">{% trans "Hosting Package Actions" %}</div> <div class="panel-heading">{% trans "Hosting Package Actions" %}</div>
<ul class="list-group"> <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="#" 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> </ul>
</div> </div>
</div> </div>
@ -76,7 +76,7 @@
<div class="col-lg-12 col-md-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-xs-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">{% trans "Domains" %}</div> <div class="panel-heading">{% trans "Domains" %}</div>
{% if hostingpackage.domains %} {% if domains %}
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>
<tr> <tr>
@ -87,7 +87,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for domain in hostingpackage.domains.all %} {% for domain in domains %}
<tr> <tr>
<td>{{ domain.domain }}</td> <td>{{ domain.domain }}</td>
{% if domain.domain.maildomain %} {% if domain.domain.maildomain %}
@ -126,7 +126,7 @@
<div class="col-lg-12 col-md-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-xs-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">{% trans "E-Mail-Accounts" %}</div> <div class="panel-heading">{% trans "E-Mail-Accounts" %}</div>
{% if hostingpackage.mailboxes %} {% if mailboxes %}
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>
<tr> <tr>
@ -137,7 +137,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for mailbox in hostingpackage.mailboxes %} {% for mailbox in mailboxes %}
<tr> <tr>
<td>{{ mailbox.username }}</td> <td>{{ mailbox.username }}</td>
<td>{{ mailbox.mailaddresses|join:", " }}</td> <td>{{ mailbox.mailaddresses|join:", " }}</td>
@ -161,7 +161,7 @@
<div class="col-lg-12 col-md-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-xs-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">{% trans "Databases" %}</div> <div class="panel-heading">{% trans "Databases" %}</div>
{% if hostingpackage.databases %} {% if databases %}
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>
<tr> <tr>
@ -172,11 +172,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for database in hostingpackage.databases %} {% for database in databases %}
<tr> <tr>
<td>{% include "userdbs/snippets/db_type.html" with db_type=database.db_user.db_type %}</td> <td>{% include "userdbs/snippets/db_type.html" with db_type=database.db_user.db_type %}</td>
<td>{{ database.db_name }}</td> <td>{{ database.db_name }}</td>
<td>{{ database.db_user.username }}</td> <td>{{ database.db_user.name }}</td>
<td></td> <td></td>
</tr> </tr>
{% endfor %} {% endfor %}