Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove useless fix for the time-zones in archive views, since we use …

…Django 1.5
  • Loading branch information...
commit 115d180ecc1cc79e3a2532db7d4cb537823f10f1 1 parent a8e5ef7
@Fantomas42 authored
View
11 zinnia/views/archives.py
@@ -18,9 +18,6 @@
EntryQuerysetArchiveTemplateResponseMixin
from zinnia.views.mixins.templates import \
EntryQuerysetArchiveTodayTemplateResponseMixin
-from zinnia.views.mixins.tz_fixes import EntryDayTZFix
-from zinnia.views.mixins.tz_fixes import EntryWeekTZFix
-from zinnia.views.mixins.tz_fixes import EntryMonthTZFix
class EntryArchiveMixin(ArchiveMixin,
@@ -58,14 +55,14 @@ class EntryYear(EntryArchiveMixin, BaseYearArchiveView):
template_name_suffix = '_archive_year'
-class EntryMonth(EntryMonthTZFix, EntryArchiveMixin, BaseMonthArchiveView):
+class EntryMonth(EntryArchiveMixin, BaseMonthArchiveView):
"""
View returning the archives for a month.
"""
template_name_suffix = '_archive_month'
-class EntryWeek(EntryWeekTZFix, EntryArchiveMixin, BaseWeekArchiveView):
+class EntryWeek(EntryArchiveMixin, BaseWeekArchiveView):
"""
View returning the archive for a week.
"""
@@ -83,14 +80,14 @@ def get_dated_items(self):
return self.date_list, self.object_list, extra_context
-class EntryDay(EntryDayTZFix, EntryArchiveMixin, BaseDayArchiveView):
+class EntryDay(EntryArchiveMixin, BaseDayArchiveView):
"""
View returning the archive for a day.
"""
template_name_suffix = '_archive_day'
-class EntryToday(EntryDayTZFix, EntryArchiveMixin, BaseTodayArchiveView):
+class EntryToday(EntryArchiveMixin, BaseTodayArchiveView):
"""
View returning the archive for the current day.
"""
View
6 zinnia/views/entries.py
@@ -6,11 +6,9 @@
from zinnia.views.mixins.entry_protection import EntryProtectionMixin
from zinnia.views.mixins.callable_queryset import CallableQuerysetMixin
from zinnia.views.mixins.templates import EntryArchiveTemplateResponseMixin
-from zinnia.views.mixins.tz_fixes import EntryDateDetailTZFix
-class EntryDateDetail(EntryDateDetailTZFix,
- ArchiveMixin,
+class EntryDateDetail(ArchiveMixin,
EntryArchiveTemplateResponseMixin,
CallableQuerysetMixin,
BaseDateDetailView):
@@ -23,8 +21,6 @@ class EntryDateDetail(EntryDateDetailTZFix,
- BaseDateDetailView to retrieve the entry with date and slug
- CallableQueryMixin to defer the execution of the *queryset*
property when imported
- - EntryDateDetailTZFix for handing the time-zones correctly
- in Django 1.4.
"""
queryset = Entry.published.on_site
View
121 zinnia/views/mixins/tz_fixes.py
@@ -1,121 +0,0 @@
-"""
-Mixins for fixing the time zones support in the
-class based generic views for archives.
-
-This module must be removed in Django 1.5.
-
-https://code.djangoproject.com/ticket/18217
-"""
-import datetime
-
-from django.conf import settings
-from django.utils import timezone
-from django.views.generic.dates import _date_from_string
-from django.views.generic.detail import BaseDetailView
-
-
-def _make_date_lookup(value):
- value = datetime.datetime.combine(value, datetime.time.min)
- if settings.USE_TZ:
- value = timezone.make_aware(value, timezone.get_current_timezone())
- return value
-
-
-def _date_lookup_for_field(value):
- """Here the main node of the problem"""
- since = _make_date_lookup(value)
- until = _make_date_lookup(value + datetime.timedelta(days=1))
- return {
- 'creation_date__gte': since,
- 'creation_date__lt': until}
-
-
-class EntryMonthTZFix(object):
-
- def get_dated_items(self):
- """
- Return (date_list, items, extra_context) for this request.
- """
- year = self.get_year()
- month = self.get_month()
- date = _date_from_string(year, self.get_year_format(),
- month, self.get_month_format())
-
- since = _make_date_lookup(date)
- if date.month == 12:
- until = _make_date_lookup(
- datetime.date(date.year + 1, 1, 1))
- else:
- until = _make_date_lookup(
- datetime.date(date.year, date.month + 1, 1))
- lookup_kwargs = {
- 'creation_date__gte': since,
- 'creation_date__lt': until}
-
- qs = self.get_dated_queryset(**lookup_kwargs)
- date_list = self.get_date_list(qs, 'day')
-
- return (date_list, qs, {
- 'month': date,
- 'next_month': self.get_next_month(date),
- 'previous_month': self.get_previous_month(date)})
-
-
-class EntryWeekTZFix(object):
-
- def get_dated_items(self):
- """
- Return (date_list, items, extra_context) for this request.
- """
- year = self.get_year()
- week = self.get_week()
- week_format = self.get_week_format()
- week_start = {'%W': '1', '%U': '0'}[week_format]
- date = _date_from_string(year, self.get_year_format(),
- week_start, '%w',
- week, week_format)
- since = _make_date_lookup(date)
- until = _make_date_lookup(date + datetime.timedelta(days=7))
- lookup_kwargs = {
- 'creation_date__gte': since,
- 'creation_date__lt': until}
-
- qs = self.get_dated_queryset(**lookup_kwargs)
-
- return (None, qs, {'week': date})
-
-
-class EntryDayTZFix(object):
-
- def _get_dated_items(self, date):
- """
- Do the actual heavy lifting of getting the dated items; this accepts a
- date object so that TodayArchiveView can be trivial.
- """
- lookup_kwargs = _date_lookup_for_field(date)
- qs = self.get_dated_queryset(**lookup_kwargs)
-
- return (None, qs, {
- 'day': date,
- 'previous_day': self.get_previous_day(date),
- 'next_day': self.get_next_day(date),
- 'previous_month': self.get_previous_month(date),
- 'next_month': self.get_next_month(date)})
-
-
-class EntryDateDetailTZFix(object):
-
- def get_object(self, queryset=None):
- """
- Get the object this request displays.
- """
- year = self.get_year()
- month = self.get_month()
- day = self.get_day()
- date = _date_from_string(year, self.get_year_format(),
- month, self.get_month_format(),
- day, self.get_day_format())
- qs = queryset or self.get_queryset()
- lookup = _date_lookup_for_field(date)
- qs = qs.filter(**lookup)
- return super(BaseDetailView, self).get_object(queryset=qs)
Please sign in to comment.
Something went wrong with that request. Please try again.