allow image page sizes to be configurable (#5568)

pull/5581/head
Brian Whitton 2019-09-13 16:37:59 -04:00 zatwierdzone przez Matt Westcott
rodzic a7b470bc9d
commit 34f4ab8a3f
6 zmienionych plików z 35 dodań i 5 usunięć

Wyświetl plik

@ -20,6 +20,7 @@ Changelog
* Recognise Soundcloud artist URLs as embeddable (Kiril Staikov)
* Add `WAGTAILDOCS_SERVE_METHOD` setting to determine how document downloads will be linked to and served (Tobias McNulty, Matt Westcott)
* Add `WAGTAIL_MODERATION_ENABLED` setting to enable / disable the 'Submit for Moderation' option (Jacob Topp-Mugglestone)
* Added settings to customise pagination page size for the Images admin area (Brian Whitton)
* Fix: Added line breaks to long filenames on multiple image / document uploader (Kevin Howbrook)
* Fix: Added https support for Scribd oEmbed provider (Rodrigo)
* Fix: Changed StreamField group labels color so labels are visible (Catherine Farman)

Wyświetl plik

@ -407,6 +407,7 @@ Contributors
* Dawid Bugajewski
* Dawn Wages
* Jacob Topp-Mugglestone
* Brian Whitton
Translators
===========

Wyświetl plik

@ -275,6 +275,24 @@ This setting lets you override the maximum number of pixels an image can have. I
This setting enables feature detection once OpenCV is installed, see all details on the :ref:`image_feature_detection` documentation.
.. code-block:: python
WAGTAILIMAGES_INDEX_PAGE_SIZE = 20
Specifies the number of images per page shown on the main Images listing in the Wagtail admin.
.. code-block:: python
WAGTAILIMAGES_USAGE_PAGE_SIZE = 20
Specifies the number of items per page shown when viewing an image's usage (see :ref:`WAGTAIL_USAGE_COUNT_ENABLED <WAGTAIL_USAGE_COUNT_ENABLED>`).
.. code-block:: python
WAGTAILIMAGES_CHOOSER_PAGE_SIZE = 12
Specifies the number of images shown per page in the image chooser modal.
Documents
---------
@ -475,6 +493,8 @@ a custom user model is being used and extra fields are required in the user crea
A list of the extra custom fields to be appended to the default list.
.. _WAGTAIL_USAGE_COUNT_ENABLED:
Usage for images, documents and snippets
----------------------------------------

Wyświetl plik

@ -39,6 +39,7 @@ Other features
* Recognise Soundcloud artist URLs as embeddable (Kiril Staikov)
* Add ``WAGTAILDOCS_SERVE_METHOD`` setting to determine how document downloads will be linked to and served (Tobias McNulty, Matt Westcott)
* Add ``WAGTAIL_MODERATION_ENABLED`` setting to enable / disable the 'Submit for Moderation' option (Jacob Topp-Mugglestone)
* Added settings to customise pagination page size for the Images admin area (Brian Whitton)
Bug fixes

Wyświetl plik

@ -1,3 +1,4 @@
from django.conf import settings
from django.core.paginator import Paginator
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
@ -17,6 +18,8 @@ from wagtail.search import index as search_index
permission_checker = PermissionPolicyChecker(permission_policy)
CHOOSER_PAGE_SIZE = getattr(settings, 'WAGTAILIMAGES_CHOOSER_PAGE_SIZE', 12)
def get_chooser_js_data():
"""construct context variables needed by the chooser JS"""
@ -106,7 +109,7 @@ def chooser(request):
images = images.filter(tags__name=tag_name)
# Pagination
paginator = Paginator(images, per_page=12)
paginator = Paginator(images, per_page=CHOOSER_PAGE_SIZE)
images = paginator.get_page(request.GET.get('p'))
return render(request, "wagtailimages/chooser/results.html", {
@ -116,7 +119,7 @@ def chooser(request):
'will_select_format': request.GET.get('select_format')
})
else:
paginator = Paginator(images, per_page=12)
paginator = Paginator(images, per_page=CHOOSER_PAGE_SIZE)
images = paginator.get_page(request.GET.get('p'))
context = get_chooser_context(request)
@ -187,7 +190,7 @@ def chooser_upload(request):
for hook in hooks.get_hooks('construct_image_chooser_queryset'):
images = hook(images, request)
paginator = Paginator(images, per_page=12)
paginator = Paginator(images, per_page=CHOOSER_PAGE_SIZE)
images = paginator.get_page(request.GET.get('p'))
context = get_chooser_context(request)

Wyświetl plik

@ -1,5 +1,6 @@
import os
from django.conf import settings
from django.core.paginator import Paginator
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
@ -23,6 +24,9 @@ from wagtail.search import index as search_index
permission_checker = PermissionPolicyChecker(permission_policy)
INDEX_PAGE_SIZE = getattr(settings, 'WAGTAILIMAGES_INDEX_PAGE_SIZE', 20)
USAGE_PAGE_SIZE = getattr(settings, 'WAGTAILIMAGES_USAGE_PAGE_SIZE', 20)
@permission_checker.require_any('add', 'change', 'delete')
@vary_on_headers('X-Requested-With')
@ -55,7 +59,7 @@ def index(request):
except (ValueError, Collection.DoesNotExist):
pass
paginator = Paginator(images, per_page=20)
paginator = Paginator(images, per_page=INDEX_PAGE_SIZE)
images = paginator.get_page(request.GET.get('p'))
collections = permission_policy.collections_user_has_any_permission_for(
@ -289,7 +293,7 @@ def add(request):
def usage(request, image_id):
image = get_object_or_404(get_image_model(), id=image_id)
paginator = Paginator(image.get_usage(), per_page=20)
paginator = Paginator(image.get_usage(), per_page=USAGE_PAGE_SIZE)
used_by = paginator.get_page(request.GET.get('p'))
return render(request, "wagtailimages/images/usage.html", {