Closes #3314: Paginate object changelog entries

This commit is contained in:
Jeremy Stretch 2019-07-18 21:40:36 -04:00
parent 86b6b9bf8b
commit cab3c50ae6
3 changed files with 12 additions and 3 deletions

View File

@ -4,6 +4,7 @@ v2.6.2 (FUTURE)
* [#984](https://github.com/netbox-community/netbox/issues/984) - Allow ordering circuits by A/Z side * [#984](https://github.com/netbox-community/netbox/issues/984) - Allow ordering circuits by A/Z side
* [#3307](https://github.com/netbox-community/netbox/issues/3307) - Add power panels count to home page * [#3307](https://github.com/netbox-community/netbox/issues/3307) - Add power panels count to home page
* [#3314](https://github.com/netbox-community/netbox/issues/3314) - Paginate object changelog entries
## Bug Fixes ## Bug Fixes

View File

@ -228,6 +228,13 @@ class ObjectChangeLogView(View):
orderable=False orderable=False
) )
# Apply the request context
paginate = {
'paginator_class': EnhancedPaginator,
'per_page': request.GET.get('per_page', settings.PAGINATE_COUNT)
}
RequestConfig(request, paginate).configure(objectchanges_table)
# Check whether a header template exists for this model # Check whether a header template exists for this model
base_template = '{}/{}.html'.format(model._meta.app_label, model._meta.model_name) base_template = '{}/{}.html'.format(model._meta.app_label, model._meta.model_name)
try: try:
@ -239,7 +246,7 @@ class ObjectChangeLogView(View):
return render(request, 'extras/object_changelog.html', { return render(request, 'extras/object_changelog.html', {
object_var: obj, object_var: obj,
'objectchanges_table': objectchanges_table, 'table': objectchanges_table,
'base_template': base_template, 'base_template': base_template,
'active_tab': 'changelog', 'active_tab': 'changelog',
}) })

View File

@ -4,9 +4,10 @@
{% block content %} {% block content %}
{% if obj %}<h1>{{ obj }}</h1>{% endif %} {% if obj %}<h1>{{ obj }}</h1>{% endif %}
{% include 'panel_table.html' with table=objectchanges_table %} {% include 'panel_table.html' %}
{% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
{% if settings.CHANGELOG_RETENTION %} {% if settings.CHANGELOG_RETENTION %}
<div class="pull-right text-muted"> <div class="text-muted">
Changelog retention: {{ settings.CHANGELOG_RETENTION }} days Changelog retention: {{ settings.CHANGELOG_RETENTION }} days
</div> </div>
{% endif %} {% endif %}