Skip to content

Commit

Permalink
feat: add pagination to views
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Dec 10, 2024
1 parent 62dade4 commit a52c9e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apis_acdhch_django_auditlog/templates/auditlog/logentry_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
</li>
{% endfor %}
</ul>
<div class="pagination justify-content-center">
<span class="step-links">
{% if page_obj.has_previous %}
<a href="?page=1">&laquo; first</a>
<a href="?page={{ page_obj.previous_page_number }}">previous</a>
{% endif %}
<span class="current">Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}">next</a>
<a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a>
{% endif %}
</span>
</div>
{% endif %}
</div>
{% endblock content %}
3 changes: 3 additions & 0 deletions apis_acdhch_django_auditlog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@


class UserAuditLog(LoginRequiredMixin, ListView):
paginate_by = 100

def get_queryset(self, *args, **kwargs):
return LogEntry.objects.filter(actor=self.request.user)


class AuditLog(UserPassesTestMixin, ListView):
model = LogEntry
paginate_by = 100

def test_func(self):
return self.request.user.is_superuser

0 comments on commit a52c9e9

Please sign in to comment.