fixed /admin
|  | @ -1,6 +1,7 @@ | ||||||
| # from django.views.generic.list_detail import object_list | # from django.views.generic.list_detail import object_list | ||||||
| from django.views.generic import ListView | from django.views.generic import ListView | ||||||
| from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView | from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView | ||||||
|  | from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger | ||||||
| from conservancy.apps.news.models import ExternalArticle | from conservancy.apps.news.models import ExternalArticle | ||||||
| from conservancy.apps.events.models import Event | from conservancy.apps.events.models import Event | ||||||
| from datetime import datetime | from datetime import datetime | ||||||
|  | @ -41,18 +42,35 @@ def custom_index(request, queryset, *args, **kwargs): | ||||||
| 
 | 
 | ||||||
|     date_list = queryset.dates(kwargs['date_field'], 'year') |     date_list = queryset.dates(kwargs['date_field'], 'year') | ||||||
| 
 | 
 | ||||||
|  |     paginate_by = kwargs.get('paginate_by', 6) | ||||||
|  |     paginator = Paginator(queryset, paginate_by) | ||||||
|  |     page = request.GET.get('page') | ||||||
|  |     try: | ||||||
|  |         p = paginator.page(page) | ||||||
|  |     except PageNotAnInteger: | ||||||
|  |         # If page is not an integer, deliver first page. | ||||||
|  |         p = paginator.page(1) | ||||||
|  |         page = 1 | ||||||
|  |     except EmptyPage: | ||||||
|  |         # If page is out of range (e.g. 9999), deliver last page of results. | ||||||
|  |         p = paginator.page(paginator.num_pages) | ||||||
|  |         page = paginator.num_pages | ||||||
|     kwargs = dict(kwargs, extra_context={'articles': articles, |     kwargs = dict(kwargs, extra_context={'articles': articles, | ||||||
|                                          'date_list': date_list, |                                          'date_list': date_list, | ||||||
|                                          'future_events': future_events, |                                          'future_events': future_events, | ||||||
|                                          'past_events': past_events, |                                          'past_events': past_events, | ||||||
|                                          'page': 1}) |                                          # 'paginator': paginator, | ||||||
|  |                                          'page': page, | ||||||
|  |                                          # 'is_paginated': True, | ||||||
|  |                                          # 'num_pages': paginator.num_pages | ||||||
|  |                                      }) | ||||||
|     del kwargs['date_field'] |     del kwargs['date_field'] | ||||||
|  |     kwargs['queryset'] = queryset | ||||||
|      |      | ||||||
|     # return object_list(request, queryset, *args, **kwargs) |     # return object_list(request, queryset, *args, **kwargs) | ||||||
|     # callable = NewsListView.as_view(queryset=queryset, |     # callable = NewsListView.as_view(queryset=queryset, | ||||||
|     #                                 extra_context=kwargs, |     #                                 extra_context=kwargs, | ||||||
|     #                                 paginate_by=kwargs['paginate_by']) |     #                                 paginate_by=kwargs['paginate_by']) | ||||||
|     kwargs['queryset'] = queryset |  | ||||||
|     callable = NewsListView.as_view(**kwargs) |     callable = NewsListView.as_view(**kwargs) | ||||||
|     return callable(request) |     return callable(request) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
| Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 80 B | 
| Before Width: | Height: | Size: 838 B After Width: | Height: | Size: 838 B | 
| Before Width: | Height: | Size: 58 B After Width: | Height: | Size: 58 B | 
| Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 199 B | 
| Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 212 B | 
| Before Width: | Height: | Size: 843 B After Width: | Height: | Size: 843 B | 
| Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 844 B | 
| Before Width: | Height: | Size: 45 B After Width: | Height: | Size: 45 B | 
| Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B | 
| Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 130 B | 
| Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 299 B | 
| Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B | 
| Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 145 B | 
| Before Width: | Height: | Size: 192 B After Width: | Height: | Size: 192 B | 
| Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B | 
| Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B | 
| Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B | 
| Before Width: | Height: | Size: 319 B After Width: | Height: | Size: 319 B | 
| Before Width: | Height: | Size: 667 B After Width: | Height: | Size: 667 B | 
| Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 341 B | 
| Before Width: | Height: | Size: 477 B After Width: | Height: | Size: 477 B | 
| Before Width: | Height: | Size: 781 B After Width: | Height: | Size: 781 B | 
| Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 447 B | 
| Before Width: | Height: | Size: 623 B After Width: | Height: | Size: 623 B | 
| Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B | 
| Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B | 
| Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B | 
| Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 273 B | 
| Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B | 
| Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 358 B | 
| Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 398 B | 
| Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 355 B | 
| Before Width: | Height: | Size: 552 B After Width: | Height: | Size: 552 B | 
| Before Width: | Height: | Size: 612 B After Width: | Height: | Size: 612 B | 
| Before Width: | Height: | Size: 401 B After Width: | Height: | Size: 401 B | 
| Before Width: | Height: | Size: 197 B After Width: | Height: | Size: 197 B | 
| Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B | 
| Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B | 
| Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 200 B | 
| Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 932 B | 
| Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B | 
| Before Width: | Height: | Size: 351 B After Width: | Height: | Size: 351 B | 
| Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B | 
 Tom Marble
						Tom Marble