Просмотр исходного кода

Closes #3314: Paginate object changelog entries

Jeremy Stretch 6 лет назад
Родитель
Сommit
cab3c50ae6
3 измененных файлов с 12 добавлено и 3 удалено
  1. 1 0
      CHANGELOG.md
  2. 8 1
      netbox/extras/views.py
  3. 3 2
      netbox/templates/extras/object_changelog.html

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@ v2.6.2 (FUTURE)
 
 * [#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
+* [#3314](https://github.com/netbox-community/netbox/issues/3314) - Paginate object changelog entries
 
 ## Bug Fixes
 

+ 8 - 1
netbox/extras/views.py

@@ -228,6 +228,13 @@ class ObjectChangeLogView(View):
             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
         base_template = '{}/{}.html'.format(model._meta.app_label, model._meta.model_name)
         try:
@@ -239,7 +246,7 @@ class ObjectChangeLogView(View):
 
         return render(request, 'extras/object_changelog.html', {
             object_var: obj,
-            'objectchanges_table': objectchanges_table,
+            'table': objectchanges_table,
             'base_template': base_template,
             'active_tab': 'changelog',
         })

+ 3 - 2
netbox/templates/extras/object_changelog.html

@@ -4,9 +4,10 @@
 
 {% block content %}
     {% 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 %}
-        <div class="pull-right text-muted">
+        <div class="text-muted">
             Changelog retention: {{ settings.CHANGELOG_RETENTION }} days
         </div>
     {% endif %}