68 | | queryset = easy_model.get_query_set() |
69 | | extra_context = {'root_url': self.site.root_url, 'model': easy_model, 'field': field} |
| 68 | root_url = self.site.root_url |
| 69 | |
| 70 | class DateViewMixin(object): |
| 71 | allow_empty = False |
| 72 | allow_future = True |
| 73 | date_field = field.name |
| 74 | queryset = easy_model.get_query_set() |
| 75 | def get_context_data(self, **kwargs): |
| 76 | context = super(DateViewMixin, self).get_context_data(**kwargs) |
| 77 | context.update({'root_url': root_url, 'model': easy_model, 'field': field}) |
| 78 | return context |
| 79 | |
71 | | return date_based.archive_day(request, year, month, day, queryset, field.name, |
72 | | template_name='databrowse/calendar_day.html', allow_empty=False, allow_future=True, |
73 | | extra_context=extra_context) |
| 81 | class DayView(DateViewMixin, dates.DayArchiveView): |
| 82 | template_name = 'databrowse/calendar_day.html' |
| 83 | return DayView.as_view(year=year, month=month, day=day)(request) |
75 | | return date_based.archive_month(request, year, month, queryset, field.name, |
76 | | template_name='databrowse/calendar_month.html', allow_empty=False, allow_future=True, |
77 | | extra_context=extra_context) |
| 85 | class MonthView(DateViewMixin, dates.MonthArchiveView): |
| 86 | template_name = 'databrowse/calendar_month.html' |
| 87 | return MonthView.as_view(year=year, month=month)(request) |
79 | | return date_based.archive_year(request, year, queryset, field.name, |
80 | | template_name='databrowse/calendar_year.html', allow_empty=False, allow_future=True, |
81 | | extra_context=extra_context) |
| 89 | class YearView(DateViewMixin, dates.YearArchiveView): |
| 90 | template_name = 'databrowse/calendar_year.html' |
| 91 | return YearView.as_view(year=year)(request) |
83 | | return date_based.archive_index(request, queryset, field.name, |
84 | | template_name='databrowse/calendar_main.html', allow_empty=True, allow_future=True, |
85 | | extra_context=extra_context) |
| 93 | class IndexView(DateViewMixin, dates.ArchiveIndexView): |
| 94 | template_name = 'databrowse/calendar_main.html' |
| 95 | return IndexView.as_view()(request) |
| 96 | |