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

Use settings to control pagination_by values

master
David Winterbottom 10 лет назад
Родитель
Сommit
35d399e14d

+ 0
- 1
docs/source/internals/contributing/running-tests.rst Просмотреть файл

@@ -29,7 +29,6 @@ You can also run tests which match an expression via::
29 29
 
30 30
     $ ./runtests.py tests/unit/offer/availability_tests.py -k is_unavailable
31 31
 
32
-
33 32
 Testing against different setups
34 33
 --------------------------------
35 34
 

+ 3
- 3
src/oscar/apps/catalogue/reviews/views.py Просмотреть файл

@@ -1,10 +1,10 @@
1 1
 from django.shortcuts import get_object_or_404, redirect
2 2
 from django.views.generic import ListView, DetailView, CreateView, View
3 3
 from django.contrib import messages
4
-from oscar.core.loading import get_model
5 4
 from django.utils.translation import ugettext_lazy as _
5
+from django.conf import settings
6 6
 
7
-from oscar.core.loading import get_classes
7
+from oscar.core.loading import get_model, get_classes
8 8
 from oscar.core.utils import redirect_to_referrer
9 9
 from oscar.apps.catalogue.reviews.signals import review_added
10 10
 
@@ -110,7 +110,7 @@ class ProductReviewList(ListView):
110 110
     context_object_name = "reviews"
111 111
     model = ProductReview
112 112
     product_model = Product
113
-    paginate_by = 20
113
+    paginate_by = settings.OSCAR_REVIEWS_PER_PAGE
114 114
 
115 115
     def get_queryset(self):
116 116
         qs = self.model.approved.filter(product=self.kwargs['product_pk'])

+ 2
- 1
src/oscar/apps/customer/notifications/views.py Просмотреть файл

@@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _, ungettext
3 3
 from django.utils.timezone import now
4 4
 from django.contrib import messages
5 5
 from django.views import generic
6
+from django.conf import settings
6 7
 
7 8
 from oscar.core.loading import get_model
8 9
 from oscar.core.utils import redirect_to_referrer
@@ -16,7 +17,7 @@ class NotificationListView(PageTitleMixin, generic.ListView):
16 17
     model = Notification
17 18
     template_name = 'customer/notifications/list.html'
18 19
     context_object_name = 'notifications'
19
-    paginate_by = 20
20
+    paginate_by = settings.OSCAR_NOTIFICATIONS_PER_PAGE
20 21
     page_title = _("Notifications")
21 22
     active_tab = 'notifications'
22 23
 

+ 3
- 3
src/oscar/apps/customer/views.py Просмотреть файл

@@ -399,7 +399,7 @@ class ChangePasswordView(PageTitleMixin, generic.FormView):
399 399
 class EmailHistoryView(PageTitleMixin, generic.ListView):
400 400
     context_object_name = "emails"
401 401
     template_name = 'customer/email/email_list.html'
402
-    paginate_by = 20
402
+    paginate_by = settings.OSCAR_EMAILS_PER_PAGE
403 403
     page_title = _('Email History')
404 404
     active_tab = 'emails'
405 405
 
@@ -432,7 +432,7 @@ class OrderHistoryView(PageTitleMixin, generic.ListView):
432 432
     """
433 433
     context_object_name = "orders"
434 434
     template_name = 'customer/order/order_list.html'
435
-    paginate_by = 20
435
+    paginate_by = settings.OSCAR_ORDERS_PER_PAGE
436 436
     model = Order
437 437
     form_class = OrderSearchForm
438 438
     page_title = _('Order History')
@@ -612,7 +612,7 @@ class AddressListView(PageTitleMixin, generic.ListView):
612 612
     """Customer address book"""
613 613
     context_object_name = "addresses"
614 614
     template_name = 'customer/address/address_list.html'
615
-    paginate_by = 40
615
+    paginate_by = settings.OSCAR_ADDRESSES_PER_PAGE
616 616
     active_tab = 'addresses'
617 617
     page_title = _('Address Book')
618 618
 

+ 2
- 1
src/oscar/apps/dashboard/catalogue/views.py Просмотреть файл

@@ -6,6 +6,7 @@ from django.core.urlresolvers import reverse
6 6
 from django.utils.translation import ugettext_lazy as _
7 7
 from django.shortcuts import get_object_or_404, redirect
8 8
 from django.template.loader import render_to_string
9
+from django.conf import settings
9 10
 
10 11
 from oscar.core.loading import get_classes, get_model
11 12
 
@@ -495,7 +496,7 @@ class StockAlertListView(generic.ListView):
495 496
     template_name = 'dashboard/catalogue/stockalert_list.html'
496 497
     model = StockAlert
497 498
     context_object_name = 'alerts'
498
-    paginate_by = 20
499
+    paginate_by = settings.OSCAR_STOCK_ALERTS_PER_PAGE
499 500
 
500 501
     def get_context_data(self, **kwargs):
501 502
         ctx = super(StockAlertListView, self).get_context_data(**kwargs)

+ 1
- 1
src/oscar/apps/dashboard/orders/views.py Просмотреть файл

@@ -114,7 +114,7 @@ class OrderListView(BulkEditMixin, ListView):
114 114
     context_object_name = 'orders'
115 115
     template_name = 'dashboard/orders/order_list.html'
116 116
     form_class = OrderSearchForm
117
-    paginate_by = 25
117
+    paginate_by = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
118 118
     actions = ('download_selected_orders', 'change_order_statuses')
119 119
 
120 120
     def dispatch(self, request, *args, **kwargs):

+ 3
- 3
src/oscar/apps/dashboard/pages/views.py Просмотреть файл

@@ -1,14 +1,14 @@
1 1
 from django.contrib import messages
2 2
 from django.core.exceptions import ValidationError
3 3
 from django.core.urlresolvers import reverse
4
-from oscar.core.loading import get_model
5 4
 from django.http import HttpResponseRedirect
6 5
 from django.template.loader import render_to_string
7 6
 from django.utils.translation import ugettext_lazy as _
8 7
 from django.views import generic
9
-
10 8
 from django.views.generic import ListView
9
+from django.conf import settings
11 10
 
11
+from oscar.core.loading import get_model
12 12
 from oscar.core.utils import slugify
13 13
 from oscar.core.validators import URLDoesNotExistValidator
14 14
 from oscar.apps.dashboard.pages import forms
@@ -25,7 +25,7 @@ class PageListView(ListView):
25 25
     template_name = 'dashboard/pages/index.html'
26 26
     model = FlatPage
27 27
     form_class = forms.PageSearchForm
28
-    paginate_by = 25
28
+    paginate_by = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
29 29
     desc_template = u'%(main_filter)s %(title_filter)s'
30 30
 
31 31
     def get_queryset(self):

+ 2
- 1
src/oscar/apps/dashboard/reports/views.py Просмотреть файл

@@ -2,6 +2,7 @@ from django.http import HttpResponseForbidden, Http404
2 2
 from django.template.response import TemplateResponse
3 3
 from django.views.generic import ListView
4 4
 from django.utils.translation import ugettext_lazy as _
5
+from django.conf import settings
5 6
 
6 7
 from oscar.core.loading import get_class
7 8
 ReportForm = get_class('dashboard.reports.forms', 'ReportForm')
@@ -11,7 +12,7 @@ GeneratorRepository = get_class('dashboard.reports.utils',
11 12
 
12 13
 class IndexView(ListView):
13 14
     template_name = 'dashboard/reports/index.html'
14
-    paginate_by = 25
15
+    paginate_by = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
15 16
     context_object_name = 'objects'
16 17
     report_form_class = ReportForm
17 18
     generator_repository = GeneratorRepository

+ 2
- 1
src/oscar/apps/dashboard/reviews/views.py Просмотреть файл

@@ -1,6 +1,7 @@
1 1
 import datetime
2 2
 
3 3
 from django.views import generic
4
+from django.conf import settings
4 5
 from django.db.models import Q
5 6
 from django.utils.translation import ugettext_lazy as _
6 7
 from django.core.urlresolvers import reverse
@@ -21,7 +22,7 @@ class ReviewListView(BulkEditMixin, generic.ListView):
21 22
     context_object_name = 'review_list'
22 23
     form_class = forms.ProductReviewSearchForm
23 24
     review_form_class = forms.DashboardProductReviewForm
24
-    paginate_by = 25
25
+    paginate_by = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
25 26
     actions = ('update_selected_review_status',)
26 27
     checkbox_object_name = 'review'
27 28
     desc_template = _("%(main_filter)s %(date_filter)s %(status_filter)s"

+ 2
- 1
src/oscar/apps/dashboard/users/views.py Просмотреть файл

@@ -1,4 +1,5 @@
1 1
 from django.db.models import Q
2
+from django.conf import settings
2 3
 from django.contrib import messages
3 4
 from django.shortcuts import redirect
4 5
 from django.utils.translation import ugettext_lazy as _
@@ -157,7 +158,7 @@ class ProductAlertListView(ListView):
157 158
     form_class = ProductAlertSearchForm
158 159
     context_object_name = 'alerts'
159 160
     template_name = 'dashboard/users/alerts/list.html'
160
-    paginate_by = 20
161
+    paginate_by = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
161 162
     base_description = _('All Alerts')
162 163
     description = ''
163 164
 

+ 2
- 1
src/oscar/apps/dashboard/vouchers/views.py Просмотреть файл

@@ -1,5 +1,6 @@
1 1
 import datetime
2 2
 
3
+from django.conf import settings
3 4
 from django.contrib import messages
4 5
 from django.core.urlresolvers import reverse
5 6
 from oscar.core.loading import get_model
@@ -25,7 +26,7 @@ class VoucherListView(generic.ListView):
25 26
     template_name = 'dashboard/vouchers/voucher_list.html'
26 27
     form_class = VoucherSearchForm
27 28
     description_template = _("%(main_filter)s %(name_filter)s %(code_filter)s")
28
-    paginate_by = 25
29
+    paginate_by = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
29 30
 
30 31
     def get_queryset(self):
31 32
         qs = self.model.objects.all().order_by('-date_created')

+ 9
- 3
src/oscar/defaults.py Просмотреть файл

@@ -35,11 +35,17 @@ OSCAR_UPLOAD_ROOT = '/tmp'
35 35
 OSCAR_REQUIRED_ADDRESS_FIELDS = ('first_name', 'last_name', 'line1',
36 36
                                  'line4', 'postcode', 'country')
37 37
 
38
-# Offer list settings
39
-OSCAR_OFFERS_PER_PAGE = 20
38
+# Pagination settings
40 39
 
41
-# Product list settings
40
+OSCAR_OFFERS_PER_PAGE = 20
42 41
 OSCAR_PRODUCTS_PER_PAGE = 20
42
+OSCAR_REVIEWS_PER_PAGE = 20
43
+OSCAR_NOTIFICATIONS_PER_PAGE = 20
44
+OSCAR_EMAILS_PER_PAGE = 20
45
+OSCAR_ORDERS_PER_PAGE = 20
46
+OSCAR_ADDRESSES_PER_PAGE = 20
47
+OSCAR_STOCK_ALERTS_PER_PAGE = 20
48
+OSCAR_DASHBOARD_ITEMS_PER_PAGE = 20
43 49
 
44 50
 # Checkout
45 51
 OSCAR_ALLOW_ANON_CHECKOUT = False

Загрузка…
Отмена
Сохранить