From fca827025caa9e3690891d67096f22cecd3cfe76 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Wed, 11 Jun 2014 12:59:27 +0200 Subject: [PATCH] Django 1.5 support fixes --- djangocms_blog/managers.py | 6 ++++++ djangocms_blog/models.py | 2 +- tests/test_views.py | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/djangocms_blog/managers.py b/djangocms_blog/managers.py index 7b1860b..db5dac8 100644 --- a/djangocms_blog/managers.py +++ b/djangocms_blog/managers.py @@ -74,6 +74,12 @@ class GenericDateTaggedManager(TaggedFilterItem, TranslationManager): end_date_field = "date_published_end" publish_field = "publish" + def get_queryset(self, *args, **kwargs): + try: + return super(GenericDateTaggedManager, self).get_queryset(*args, **kwargs) + except AttributeError: + return super(GenericDateTaggedManager, self).get_query_set(*args, **kwargs) + def published(self, queryset=None): queryset = self.published_future(queryset) if self.start_date_field: diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index 1357c4d..54a6d22 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -8,7 +8,7 @@ from django.db import models from django.utils import timezone from django.utils.encoding import force_text from django.utils.text import slugify -from django.utils.translation import ugettext_lazy as _, get_language +from django.utils.translation import ugettext_lazy as _ from djangocms_text_ckeditor.fields import HTMLField from filer.fields.image import FilerImageField from parler.models import TranslatableModel, TranslatedFields diff --git a/tests/test_views.py b/tests/test_views.py index 86cba63..1f9660e 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -35,7 +35,7 @@ class ViewTest(BaseTest): view_obj.kwargs = {} view_obj.object_list = view_obj.get_queryset() view_obj.paginate_by = 1 - context = view_obj.get_context_data() + context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertTrue(context['is_paginated']) self.assertEqual(list(context['post_list']), [post_2]) self.assertEqual(context['paginator'].count, 2) @@ -47,7 +47,7 @@ class ViewTest(BaseTest): activate('it') view_obj.request = request view_obj.object_list = view_obj.get_queryset() - context = view_obj.get_context_data() + context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertEqual(context['post_list'][0].title, 'Secondo post') response = view_obj.render_to_response(context) self.assertContains(response, context['post_list'][0].get_absolute_url()) @@ -113,5 +113,5 @@ class ViewTest(BaseTest): self.assertEqual(list(qs), [post_1]) view_obj.object_list = qs - context = view_obj.get_context_data() + context = view_obj.get_context_data(object_list=view_obj.object_list) self.assertEqual(context['archive_date'], date(year=date.today().year, month=date.today().month, day=1)) \ No newline at end of file