optimize database query on overview page
This commit is contained in:
parent
58f7237654
commit
4717da5ae6
@ -50,27 +50,31 @@
|
||||
<br><span class="label label-warning">{% trans "Abuse" %}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ host.get_ipv4|default_if_none:_("none")}}
|
||||
{% with ipv4=host.get_ipv4 %}
|
||||
<td>{{ ipv4|default_if_none:_("none")}}
|
||||
<br>
|
||||
{% if host.last_update_ipv4 and host.get_ipv4 %}
|
||||
{% if host.last_update_ipv4 and ipv4 %}
|
||||
({{ host.last_update_ipv4|naturaltime }},
|
||||
{% if not host.tls_update_ipv4 %}
|
||||
<span class="label label-warning">{% trans "no" %} {% else %}
|
||||
<span class="label label-success">{% endif %}{% trans "TLS" %}</span>)
|
||||
{% elif host.get_ipv4 %}
|
||||
{% elif ipv4 %}
|
||||
({% trans "unknown" %})
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>{{ host.get_ipv6|default_if_none:_("none") }}
|
||||
{% with ipv6=host.get_ipv6 %}
|
||||
<td>{{ ipv6|default_if_none:_("none") }}
|
||||
<br>
|
||||
{% if host.last_update_ipv6 and host.get_ipv6 %}
|
||||
{% if host.last_update_ipv6 and ipv6 %}
|
||||
({{ host.last_update_ipv6|naturaltime }},
|
||||
{% if not host.tls_update_ipv6 %}
|
||||
<span class="label label-warning">{% trans "no" %} {% else %}
|
||||
<span class="label label-success">{% endif %}{% trans "TLS" %}</span>)
|
||||
{% elif host.get_ipv6 %}
|
||||
{% elif ipv6 %}
|
||||
({% trans "unknown" %})
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
|
@ -191,11 +191,15 @@ class OverviewView(TemplateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(OverviewView, self).get_context_data(**kwargs)
|
||||
context['nav_overview'] = True
|
||||
context['hosts'] = Host.objects.filter(created_by=self.request.user)
|
||||
context['hosts'] = Host.objects.filter(created_by=self.request.user).select_related("domain")\
|
||||
.only("name", "comment", "available", "client_faults", "server_faults", "abuse_blocked", "abuse",
|
||||
"last_update_ipv4", "tls_update_ipv4", "last_update_ipv6", "tls_update_ipv6", "domain__name")
|
||||
context['your_domains'] = Domain.objects.filter(
|
||||
created_by=self.request.user)
|
||||
created_by=self.request.user).select_related("created_by__username")\
|
||||
.only("name", "public", "available", "comment", "created_by__username")
|
||||
context['public_domains'] = Domain.objects.filter(
|
||||
public=True).exclude(created_by=self.request.user)
|
||||
public=True).exclude(created_by=self.request.user).select_related("created_by")\
|
||||
.only("name", "public", "available", "comment", "created_by__username")
|
||||
return context
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user