pagination improved

remotes/origin/1203
Ivan Kovalkovskyi 11 years ago
parent dde59aee55
commit 537f5bc501
  1. 3
      accounts/views.py
  2. 3
      article/views.py
  3. 3
      company/views.py
  4. 3
      conference/views.py
  5. 3
      core/views.py
  6. 3
      exposition/views.py
  7. 20
      functions/custom_views.py
  8. 19
      functions/overrides.py
  9. 2
      photologue/views.py
  10. 3
      place_exposition/views.py
  11. 12
      proj/settings.py
  12. 8
      specialist_catalog/views.py
  13. 3
      translator/views.py

@ -8,7 +8,8 @@ from django.contrib.auth.decorators import login_required
from django.utils.translation import ugettext as _, get_language from django.utils.translation import ugettext as _, get_language
from django.utils import timezone from django.utils import timezone
from django_messages.forms import SendForm from django_messages.forms import SendForm
from django.views.generic import TemplateView, FormView, ListView from django.views.generic import TemplateView, FormView
from functions.custom_views import ListView
from sorl.thumbnail import get_thumbnail from sorl.thumbnail import get_thumbnail
from .forms import ChangePasswordForm, EmailAnnouncementForm, FeedFilterForm from .forms import ChangePasswordForm, EmailAnnouncementForm, FeedFilterForm
from company.forms import CreateCompanyForm from company.forms import CreateCompanyForm

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
from django.views.generic import DetailView, ListView from django.views.generic import DetailView
from functions.custom_views import ListView
from django.http import HttpResponse from django.http import HttpResponse
from models import Article from models import Article
from forms import ArticleFilterForm from forms import ArticleFilterForm

@ -2,7 +2,8 @@
import json import json
from django.http import HttpResponse from django.http import HttpResponse
from django.conf import settings from django.conf import settings
from django.views.generic import ListView, DetailView from django.views.generic import DetailView
from functions.custom_views import ListView
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _, get_language from django.utils.translation import ugettext as _, get_language
from haystack.query import EmptySearchQuerySet from haystack.query import EmptySearchQuerySet

@ -6,7 +6,8 @@ from django.http import HttpResponse, Http404, HttpResponseRedirect, HttpRespons
from django.contrib import messages from django.contrib import messages
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.views.generic import ListView, DetailView from django.views.generic import DetailView
from functions.custom_views import ListView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils import translation from django.utils import translation

@ -3,7 +3,8 @@ from country.models import Country
from city.models import City from city.models import City
from place_exposition.models import PlaceExposition from place_exposition.models import PlaceExposition
from place_conference.models import PlaceConference from place_conference.models import PlaceConference
from django.views.generic import ListView, CreateView, DeleteView, UpdateView, DetailView from django.views.generic import CreateView, DeleteView, UpdateView, DetailView
from functions.custom_views import ListView
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from functions.views_help import split_params from functions.views_help import split_params
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _

@ -4,7 +4,8 @@ import datetime
from django.http import HttpResponseRedirect, HttpResponse, HttpResponsePermanentRedirect from django.http import HttpResponseRedirect, HttpResponse, HttpResponsePermanentRedirect
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.conf import settings from django.conf import settings
from django.views.generic import ListView, DetailView from django.views.generic import DetailView
from functions.custom_views import ListView
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.http import Http404 from django.http import Http404

@ -18,9 +18,23 @@ from hvad.utils import get_translation_aware_manager
#python #python
import random import random
from django.views.generic import ListView as OldListView
from country.models import Country class ListView(OldListView):
"""
List of modules, where overrided ListView is used:
- accounts.views
- article.views
- company.views
- conference.views
- core.views
- exposition.views
- photologue.views
- place_exposition.views
- specialist_catalog.views
- translator.views
"""
paginator_class = settings.DEFAULT_PAGINATOR
@login_required @login_required
def filtered_list(request, objects, template, item_per_page=settings.ADMIN_PAGINATION): def filtered_list(request, objects, template, item_per_page=settings.ADMIN_PAGINATION):
@ -186,7 +200,7 @@ def delete_object(request, Model, Form, url, prev_page,):
return render_to_response('delete.html', args) return render_to_response('delete.html', args)
#-----class------------------ #-----class------------------
from django.views.generic import ListView, DetailView from django.views.generic import DetailView
from functions.views_help import split_params from functions.views_help import split_params
from city.models import City from city.models import City

@ -0,0 +1,19 @@
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
class SeoPaginator(Paginator):
def validate_number(self, number):
"Validates the given 1-based page number."
try:
number = int(number)
except (TypeError, ValueError):
raise PageNotAnInteger('That page number is not an integer')
if number < 1:
raise EmptyPage('That page number is less than 1')
if number > self.num_pages:
if number == 1 and self.allow_empty_first_page:
pass
else:
number = 1
return number

@ -3,7 +3,7 @@ import warnings
from django.conf import settings from django.conf import settings
from django.views.generic.dates import ArchiveIndexView, DateDetailView, DayArchiveView, MonthArchiveView, YearArchiveView from django.views.generic.dates import ArchiveIndexView, DateDetailView, DayArchiveView, MonthArchiveView, YearArchiveView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.list import ListView from functions.custom_views import ListView
from .models import Photo, Gallery from .models import Photo, Gallery
# Number of galleries to display per page. # Number of galleries to display per page.

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.views.generic import ListView, DetailView, FormView from django.views.generic import DetailView, FormView
from functions.custom_views import ListView
from django.utils import translation from django.utils import translation
from django.http import HttpResponseRedirect, HttpResponse from django.http import HttpResponseRedirect, HttpResponse
from django.template import RequestContext from django.template import RequestContext

@ -422,10 +422,14 @@ THUMBNAIL_DEBUG = DEBUG
CALLBACK_EMAIL = 'kotzilla@ukr.net' CALLBACK_EMAIL = 'kotzilla@ukr.net'
BOOKING_AID = '333667' BOOKING_AID = '333667'
try:
from functions.overrides import SeoPaginator as Paginator
except ImportError:
from django.core.paginator import Paginator
DEFAULT_PAGINATOR = Paginator
ADMIN_PAGINATION = 20 ADMIN_PAGINATION = 20
CLIENT_PAGINATION = 15 CLIENT_PAGINATION = 15
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
NO_LOGO = '/static/client/img/no-logo.png' NO_LOGO = '/static/client/img/no-logo.png'
@ -504,4 +508,6 @@ if DEBUG:
# 'INTERCEPT_REDIRECTS': False, # 'INTERCEPT_REDIRECTS': False,
#} #}
""" """
# -- PAGINATION -- #

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.views.generic import CreateView, UpdateView, DeleteView, ListView, FormView, DetailView from django.views.generic import CreateView, UpdateView, DeleteView, FormView, DetailView
from functions.custom_views import ListView
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from .forms import * from .forms import *
@ -11,6 +12,8 @@ from django.http import HttpResponseRedirect, Http404
from .models import _city, _country from .models import _city, _country
# =========== ADMIN VIEWS =========== # =========== ADMIN VIEWS ===========
# Specialist views # Specialist views
@ -70,11 +73,12 @@ class CatalogCreateView(CreateView):
success_url = reverse_lazy("catalog_all") success_url = reverse_lazy("catalog_all")
class CatalogListView(ListView): class CatalogListView(ListView):
model = SpecialistCatalog model = SpecialistCatalog
template_name = 'admin/specialist/catalog_all.html' template_name = 'admin/specialist/catalog_all.html'
paginate_by = settings.ADMIN_PAGINATION paginate_by = settings.ADMIN_PAGINATION
paginator_class = settings.DEFAULT_PAGINATOR
def get_queryset(self): def get_queryset(self):
_GET = self.request.GET _GET = self.request.GET
query, city, country, only_cntry = _GET.get('query'), _GET.get('city'), _GET.get('country'), _GET.get('only_countries') query, city, country, only_cntry = _GET.get('query'), _GET.get('city'), _GET.get('country'), _GET.get('only_countries')

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.views.generic import ListView, DetailView from django.views.generic import DetailView
from functions.custom_views import ListView
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _

Loading…
Cancel
Save