Do not show infinitely long logs in sidebars

This commit is contained in:
Raphael Michel
2019-05-31 10:49:57 +02:00
parent a5e3bab107
commit f63907fb16
4 changed files with 53 additions and 2 deletions

View File

@@ -5,6 +5,8 @@
{% block inside %}
<h1>{% trans "Event logs" %}</h1>
<form class="form-inline helper-display-inline" action="" method="get">
<input type="hidden" name="content_type" value="{{ request.GET.content_type }}">
<input type="hidden" name="object" value="{{ request.GET.object }}">
<p>
<select name="user" class="form-control">
<option value="">{% trans "All actions" %}</option>

View File

@@ -1,7 +1,7 @@
{% load static %}
{% load i18n %}
<ul class="list-group">
{% for log in obj.all_logentries %}
{% for log in obj.top_logentries %}
<li class="list-group-item logentry">
<p class="meta">
<span class="fa fa-clock-o"></span> {{ log.datetime|date:"SHORT_DATETIME_FORMAT" }}
@@ -45,4 +45,11 @@
</p>
</li>
{% endfor %}
{% if obj.all_logentries_link and obj.top_logentries_has_more %}
<li class="list-group-item logentry">
<a href="{{ obj.all_logentries_link }}">
{% trans "View full log" %}
</a>
</li>
{% endif %}
</ul>

View File

@@ -975,6 +975,12 @@ class EventLog(EventPermissionRequiredMixin, ListView):
elif self.request.GET.get('user'):
qs = qs.filter(user_id=self.request.GET.get('user'))
if self.request.GET.get('content_type'):
qs = qs.filter(content_type=get_object_or_404(ContentType, pk=self.request.GET.get('content_type')))
if self.request.GET.get('object'):
qs = qs.filter(object_id=self.request.GET.get('object'))
return qs
def get_context_data(self, **kwargs):