Add Django 1.8 support

This commit is contained in:
Iacopo Spalletti 2015-07-19 09:37:26 +02:00
parent 3238c0f912
commit e1fecbacba
16 changed files with 50 additions and 46 deletions

View file

@ -6,8 +6,10 @@ History
0.5.0 (XXXX-XX-XX) 0.5.0 (XXXX-XX-XX)
++++++++++++++++++ ++++++++++++++++++
* Add support for Django 1.8
* Drop dependency on Django select2 * Drop dependency on Django select2
* Code cleanups * Code cleanups
* Enforce flake8 / isort checks
0.4.0 (2015-03-22) 0.4.0 (2015-03-22)
++++++++++++++++++ ++++++++++++++++++

View file

@ -11,15 +11,14 @@ HELPER_SETTINGS = dict(
], ],
ROOT_URLCONF='tests.test_utils.urls', ROOT_URLCONF='tests.test_utils.urls',
INSTALLED_APPS=[ INSTALLED_APPS=[
'admin_enhancer',
'filer', 'filer',
'parler', 'parler',
'taggit',
'meta', 'meta',
'meta_mixin', 'meta_mixin',
'easy_thumbnails', 'easy_thumbnails',
'djangocms_text_ckeditor', 'djangocms_text_ckeditor',
'cmsplugin_filer_image', 'cmsplugin_filer_image',
'taggit',
'taggit_autosuggest', 'taggit_autosuggest',
], ],
LANGUAGE_CODE='en', LANGUAGE_CODE='en',
@ -91,6 +90,12 @@ HELPER_SETTINGS = dict(
if 'test' in sys.argv or len(sys.argv) == 1: if 'test' in sys.argv or len(sys.argv) == 1:
HELPER_SETTINGS['INSTALLED_APPS'].append('django_nose') HELPER_SETTINGS['INSTALLED_APPS'].append('django_nose')
try:
import admin_enhancer
HELPER_SETTINGS['INSTALLED_APPS'].append('admin_enhancer')
except ImportError:
pass
def run(): def run():
from djangocms_helper import runner from djangocms_helper import runner

View file

@ -1,7 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from copy import deepcopy from copy import deepcopy
from admin_enhancer.admin import EnhancedModelAdminMixin try:
from admin_enhancer.admin import EnhancedModelAdminMixin
except ImportError:
class EnhancedModelAdminMixin(object):
pass
from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin from cms.admin.placeholderadmin import FrontendEditableAdminMixin, PlaceholderAdminMixin
from django import forms from django import forms
from django.conf import settings from django.conf import settings

View file

@ -1,25 +1,24 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models, migrations
import taggit_autosuggest.managers
import filer.fields.image
import meta_mixin.models
import djangocms_text_ckeditor.fields
import cms.models.fields import cms.models.fields
import django.utils.timezone import django.utils.timezone
import djangocms_text_ckeditor.fields
import filer.fields.image
import meta_mixin.models
import taggit_autosuggest.managers
from django.conf import settings from django.conf import settings
from django.conf import settings from django.db import models, migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cms', '0003_auto_20140926_2347'), ('cms', '__latest__'),
('taggit', '__first__'), ('taggit', '__latest__'),
('filer', '0001_initial'), ('filer', '__latest__'),
('cmsplugin_filer_image', '0001_initial'), ('cmsplugin_filer_image', '__latest__'),
] ]
operations = [ operations = [

View file

@ -7,7 +7,7 @@ from django.db import models, migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('sites', '0001_initial'), ('sites', '__latest__'),
('djangocms_blog', '0001_initial'), ('djangocms_blog', '0001_initial'),
] ]

View file

@ -1,8 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from cms.models import CMSPlugin, PlaceholderField from cms.models import CMSPlugin, PlaceholderField
from cmsplugin_filer_image.models import ThumbnailOption
from django.conf import settings as dj_settings from django.conf import settings as dj_settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
@ -87,31 +85,28 @@ class Post(ModelMeta, TranslatableModel):
date_published_end = models.DateTimeField(_(u'published Until'), null=True, date_published_end = models.DateTimeField(_(u'published Until'), null=True,
blank=True) blank=True)
publish = models.BooleanField(_(u'publish'), default=False) publish = models.BooleanField(_(u'publish'), default=False)
categories = models.ManyToManyField(BlogCategory, verbose_name=_(u'category'), categories = models.ManyToManyField('djangocms_blog.BlogCategory', verbose_name=_(u'category'),
related_name='blog_posts',) related_name='blog_posts',)
main_image = FilerImageField(verbose_name=_(u'main image'), blank=True, null=True, main_image = FilerImageField(verbose_name=_(u'main image'), blank=True, null=True,
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
related_name='djangocms_blog_post_image') related_name='djangocms_blog_post_image')
main_image_thumbnail = models.ForeignKey(ThumbnailOption, main_image_thumbnail = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption',
verbose_name=_(u'main image thumbnail'), verbose_name=_(u'main image thumbnail'),
related_name='djangocms_blog_post_thumbnail', related_name='djangocms_blog_post_thumbnail',
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
blank=True, null=True) blank=True, null=True)
main_image_full = models.ForeignKey(ThumbnailOption, main_image_full = models.ForeignKey('cmsplugin_filer_image.ThumbnailOption',
verbose_name=_(u'main image full'), verbose_name=_(u'main image full'),
related_name='djangocms_blog_post_full', related_name='djangocms_blog_post_full',
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
blank=True, null=True) blank=True, null=True)
enable_comments = models.BooleanField( enable_comments = models.BooleanField(verbose_name=_(u'enable comments on post'),
verbose_name=_(u'enable comments on post'), default=get_setting('ENABLE_COMMENTS'))
default=get_setting('ENABLE_COMMENTS') sites = models.ManyToManyField('sites.Site', verbose_name=_(u'Site(s)'), blank=True,
)
sites = models.ManyToManyField(Site, verbose_name=_(u'Site(s)'), blank=True,
null=True, null=True,
help_text=_(u'Select sites in which to show the post. ' help_text=_(u'Select sites in which to show the post. '
u'If none is set it will be ' u'If none is set it will be '
u'visible in all the configured sites.') u'visible in all the configured sites.'))
)
translations = TranslatedFields( translations = TranslatedFields(
title=models.CharField(_(u'title'), max_length=255), title=models.CharField(_(u'title'), max_length=255),
@ -254,7 +249,7 @@ class LatestPostsPlugin(BasePostPlugin):
help_text=_(u'The number of latests articles to be displayed.')) help_text=_(u'The number of latests articles to be displayed.'))
tags = models.ManyToManyField('taggit.Tag', blank=True, verbose_name=_(u'filter by tag'), tags = models.ManyToManyField('taggit.Tag', blank=True, verbose_name=_(u'filter by tag'),
help_text=_(u'Show only the blog articles tagged with chosen tags.')) help_text=_(u'Show only the blog articles tagged with chosen tags.'))
categories = models.ManyToManyField('BlogCategory', blank=True, verbose_name=_(u'filter by category'), categories = models.ManyToManyField('djangocms_blog.BlogCategory', blank=True, verbose_name=_(u'filter by category'),
help_text=_(u'Show only the blog articles tagged with chosen categories.')) help_text=_(u'Show only the blog articles tagged with chosen categories.'))
def __str__(self): def __str__(self):

View file

@ -1,5 +1,4 @@
{% load i18n thumbnail cms_tags %} {% load i18n thumbnail cms_tags %}
{% load url from future %}
<article id="post-{{ post.slug }}" class="post-item"> <article id="post-{{ post.slug }}" class="post-item">
<header> <header>

View file

@ -1,5 +1,4 @@
{% load i18n thumbnail cms_tags %} {% load i18n thumbnail cms_tags %}
{% load url from future %}
<ul class="post-detail"> <ul class="post-detail">
{% if post.author %} {% if post.author %}

View file

@ -1,5 +1,4 @@
{% load i18n %} {% load i18n %}{% spaceless %}
{% load url from future %}{% spaceless %}
<div class="plugin plugin-blog"> <div class="plugin plugin-blog">
<h3>{% trans "Archive" %}</h3> <h3>{% trans "Archive" %}</h3>
{% regroup dates by date.year as years %} {% regroup dates by date.year as years %}

View file

@ -1,5 +1,4 @@
{% load i18n %} {% load i18n %}{% spaceless %}
{% load url from future %}{% spaceless %}
<div class="plugin plugin-blog"> <div class="plugin plugin-blog">
<h3>{% trans "Categories" %}</h3> <h3>{% trans "Categories" %}</h3>
<ul class="blog-categories"> <ul class="blog-categories">

View file

@ -1,5 +1,4 @@
{% load i18n %} {% load i18n %}{% spaceless %}
{% load url from future %}{% spaceless %}
<div class="plugin plugin-blog"> <div class="plugin plugin-blog">
<h3>{% trans "Tags" %}</h3> <h3>{% trans "Tags" %}</h3>
<ul class="blog-tags"> <ul class="blog-tags">

View file

@ -1,6 +1,5 @@
{% extends "djangocms_blog/base.html" %} {% extends "djangocms_blog/base.html" %}
{% load i18n thumbnail cms_tags %} {% load i18n thumbnail cms_tags %}
{% load url from future %}
{% block meta_description %}{{ post.meta_description }}{% endblock meta_description %} {% block meta_description %}{{ post.meta_description }}{% endblock meta_description %}
{% block meta_keywords %}{{ post.meta_keywords }}{% endblock meta_keywords %} {% block meta_keywords %}{{ post.meta_keywords }}{% endblock meta_keywords %}

View file

@ -5,5 +5,5 @@ mock>=1.0.1
nose>=1.3.0 nose>=1.3.0
django-nose>=1.2 django-nose>=1.2
flake8 flake8
djangocms-helper>=0.7 https://github.com/nephila/djangocms-helper/archive/develop.zip
tox>=2.0 tox>=2.0

View file

@ -44,7 +44,6 @@ setup(
'pytz', 'pytz',
'django-taggit-templatetags', 'django-taggit-templatetags',
'django-taggit-autosuggest', 'django-taggit-autosuggest',
'django-admin-enhancer',
'djangocms-text-ckeditor', 'djangocms-text-ckeditor',
'cmsplugin-filer', 'cmsplugin-filer',
'django-meta>=0.2', 'django-meta>=0.2',
@ -54,6 +53,10 @@ setup(
zip_safe=False, zip_safe=False,
keywords='djangocms-blog, blog, django, wordpress, multilingual', keywords='djangocms-blog, blog, django, wordpress, multilingual',
test_suite='cms_helper.run', test_suite='cms_helper.run',
extras_require={
'admin-enhancer': ['django-admin-enhancer'],
},
classifiers=[ classifiers=[
'Development Status :: 4 - Beta', 'Development Status :: 4 - Beta',
'Framework :: Django', 'Framework :: Django',

View file

@ -26,7 +26,7 @@ class PluginTest(BaseTest):
tag = Tag.objects.get(slug='tag-1') tag = Tag.objects.get(slug='tag-1')
plugin.tags.add(tag) plugin.tags.add(tag)
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
context = RequestContext(request, {}) context = RequestContext(request, {'request': request})
rendered = plugin.render_plugin(context, ph) rendered = plugin.render_plugin(context, ph)
self.assertTrue(rendered.find('cms_plugin-djangocms_blog-post-abstract-1') > -1) self.assertTrue(rendered.find('cms_plugin-djangocms_blog-post-abstract-1') > -1)
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-tagged', kwargs={'tag': tag.slug})) > -1) self.assertTrue(rendered.find(reverse('djangocms_blog:posts-tagged', kwargs={'tag': tag.slug})) > -1)
@ -43,7 +43,7 @@ class PluginTest(BaseTest):
plugin = add_plugin(ph, 'BlogLatestEntriesPlugin', language='en') plugin = add_plugin(ph, 'BlogLatestEntriesPlugin', language='en')
plugin.categories.add(category_2) plugin.categories.add(category_2)
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
context = RequestContext(request, {}) context = RequestContext(request, {'request': request})
rendered = plugin.render_plugin(context, ph) rendered = plugin.render_plugin(context, ph)
self.assertTrue(rendered.find('cms_plugin-djangocms_blog-post-abstract-2') > -1) self.assertTrue(rendered.find('cms_plugin-djangocms_blog-post-abstract-2') > -1)
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-category', kwargs={'category': category_2.slug})) > -1) self.assertTrue(rendered.find(reverse('djangocms_blog:posts-category', kwargs={'category': category_2.slug})) > -1)
@ -63,7 +63,7 @@ class PluginTest(BaseTest):
plugin = add_plugin(ph, 'BlogAuthorPostsPlugin', language='en') plugin = add_plugin(ph, 'BlogAuthorPostsPlugin', language='en')
plugin.authors.add(self.user) plugin.authors.add(self.user)
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
context = RequestContext(request, {}) context = RequestContext(request, {'request': request})
rendered = plugin.render_plugin(context, ph) rendered = plugin.render_plugin(context, ph)
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-author', kwargs={'username': self.user.get_username()})) > -1) self.assertTrue(rendered.find(reverse('djangocms_blog:posts-author', kwargs={'username': self.user.get_username()})) > -1)
self.assertTrue(rendered.find('2 articles') > -1) self.assertTrue(rendered.find('2 articles') > -1)
@ -81,7 +81,7 @@ class PluginTest(BaseTest):
ph = page1.placeholders.get(slot='content') ph = page1.placeholders.get(slot='content')
plugin = add_plugin(ph, 'BlogTagsPlugin', language='en') plugin = add_plugin(ph, 'BlogTagsPlugin', language='en')
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
context = RequestContext(request, {}) context = RequestContext(request, {'request': request})
rendered = plugin.render_plugin(context, ph).replace("\n", "") rendered = plugin.render_plugin(context, ph).replace("\n", "")
for tag in Tag.objects.all(): for tag in Tag.objects.all():
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-tagged', kwargs={'tag': tag.slug})) > -1) self.assertTrue(rendered.find(reverse('djangocms_blog:posts-tagged', kwargs={'tag': tag.slug})) > -1)
@ -103,7 +103,7 @@ class PluginTest(BaseTest):
plugin = add_plugin(ph, 'BlogCategoryPlugin', language='en') plugin = add_plugin(ph, 'BlogCategoryPlugin', language='en')
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
plugin_class = plugin.get_plugin_class_instance() plugin_class = plugin.get_plugin_class_instance()
context = plugin_class.render(RequestContext(request, {}), plugin, ph) context = plugin_class.render(RequestContext(request, {'request': request}), plugin, ph)
self.assertTrue(context['categories']) self.assertTrue(context['categories'])
self.assertEqual(list(context['categories']), [self.category_1]) self.assertEqual(list(context['categories']), [self.category_1])
@ -118,12 +118,12 @@ class PluginTest(BaseTest):
plugin = add_plugin(ph, 'BlogArchivePlugin', language='en') plugin = add_plugin(ph, 'BlogArchivePlugin', language='en')
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True) request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
plugin_class = plugin.get_plugin_class_instance() plugin_class = plugin.get_plugin_class_instance()
context = plugin_class.render(RequestContext(request, {}), plugin, ph) context = plugin_class.render(RequestContext(request, {'request': request}), plugin, ph)
self.assertEqual(context['dates'][0]['date'].date(), now().replace(year=now().year, month=now().month, day=1).date()) self.assertEqual(context['dates'][0]['date'].date(), now().replace(year=now().year, month=now().month, day=1).date())
self.assertEqual(context['dates'][0]['count'], 2) self.assertEqual(context['dates'][0]['count'], 2)
post2.publish = False post2.publish = False
post2.save() post2.save()
context = plugin_class.render(RequestContext(request, {}), plugin, ph) context = plugin_class.render(RequestContext(request, {'request': request}), plugin, ph)
self.assertEqual(context['dates'][0]['date'].date(), now().replace(year=now().year, month=now().month, day=1).date()) self.assertEqual(context['dates'][0]['date'].date(), now().replace(year=now().year, month=now().month, day=1).date())
self.assertEqual(context['dates'][0]['count'], 1) self.assertEqual(context['dates'][0]['count'], 1)

View file

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py{26}-django{16}-cms{30,31,32},py{27,33,34}-django{16,17}-cms{30,31,32},isort,pep8 envlist = py{26}-django{16}-cms{30,31,32},py{27,33,34}-django{16,17,18}-cms{30,31,32},isort,pep8
[testenv] [testenv]
commands = {env:COMMAND:python} setup.py test commands = {env:COMMAND:python} setup.py test
@ -7,9 +7,11 @@ deps =
django16: Django>=1.6,<1.7 django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8 django17: Django>=1.7,<1.8
django18: Django>=1.7,<1.9 django18: Django>=1.7,<1.9
django18: https://github.com/stefanfoulis/django-filer/archive/develop.zip
cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
cms32: https://github.com/divio/django-cms/archive/develop.zip cms32: https://github.com/divio/django-cms/archive/develop.zip
https://github.com/nephila/djangocms-helper/archive/develop.zip
py26: unittest2 py26: unittest2
-r{toxinidir}/requirements-test.txt -r{toxinidir}/requirements-test.txt