Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Dropped support for django CMS 3.2 & 3.3 (#485)
Browse files Browse the repository at this point in the history
Introduced Django 1.11 support
  • Loading branch information
Mateusz Kamycki authored and czpython committed Apr 6, 2018
1 parent 18f15bb commit 9c43b39
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 72 deletions.
25 changes: 0 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,18 @@ matrix:
env: TOXENV=py35-dj19-sqlite-cms34
- python: '3.5'
env: TOXENV=py35-dj19-sqlite-cms34
- python: '3.5'
env: TOXENV=py35-dj19-sqlite-cms33-fe FE=1
- python: '2.7'
env: TOXENV=py27-dj111-sqlite-cms34
- python: '2.7'
env: TOXENV=py27-dj110-sqlite-cms34
- python: '2.7'
env: TOXENV=py27-dj19-sqlite-cms34
- python: '2.7'
env: TOXENV=py27-dj19-sqlite-cms33
- python: '2.7'
env: TOXENV=py27-dj19-sqlite-cms32
- python: '3.5'
env: TOXENV=py35-dj18-sqlite-cms34
- python: '3.5'
env: TOXENV=py35-dj18-sqlite-cms34
- python: '3.5'
env: TOXENV=py35-dj18-sqlite-cms33
- python: '3.5'
env: TOXENV=py35-dj18-sqlite-cms32
- python: '2.7'
env: TOXENV=py27-dj18-sqlite-cms34
- python: '2.7'
env: TOXENV=py27-dj18-sqlite-cms33-fe FE=1
- python: '2.7'
env: TOXENV=py27-dj18-sqlite-cms32
allow_failures:
- python: '2.7'
env: TOXENV=py27-dj18-sqlite-cms33-fe FE=1
- python: '3.5'
env: TOXENV=py35-dj19-sqlite-cms33-fe FE=1
- python: '3.6'
env: TOXENV=py36-dj111-sqlite-cms35
- python: '3.5'
env: TOXENV=py35-dj111-sqlite-cms35
- python: '2.7'
env: TOXENV=py27-dj111-sqlite-cms34

cache:
directories:
Expand Down
3 changes: 1 addition & 2 deletions aldryn_newsblog/cms_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class NewsBlogApp(CMSConfigApp):
name = _('NewsBlog')
app_name = 'aldryn_newsblog'
app_config = NewsBlogConfig
urls = ['aldryn_newsblog.urls'] # COMPAT: CMS3.2

def get_urls(self, *args, **kwargs):
return self.urls
return ['aldryn_newsblog.urls']

# NOTE: Please do not add a «menu» here, menu’s should only be added by at
# the discretion of the operator.
Expand Down
64 changes: 64 additions & 0 deletions aldryn_newsblog/migrations/0016_auto_20180329_1417.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-03-29 12:17
from __future__ import unicode_literals

import aldryn_apphooks_config.fields
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import filer.fields.image


TEMPLATE_PREFIX_CHOICES = getattr(
settings,
'ALDRYN_NEWSBLOG_TEMPLATE_PREFIXES',
[],
)


class Migration(migrations.Migration):

dependencies = [
('aldryn_newsblog', '0015_auto_20161208_0403'),
]

operations = [
migrations.AlterModelOptions(
name='newsblogconfig',
options={'verbose_name': 'Section', 'verbose_name_plural': 'Sections'},
),
migrations.AlterModelOptions(
name='newsblogconfigtranslation',
options={'default_permissions': (), 'managed': True, 'verbose_name': 'Section Translation'},
),
migrations.AlterField(
model_name='article',
name='app_config',
field=aldryn_apphooks_config.fields.AppHookConfigField(help_text='When selecting a value, the form is reloaded to get the updated default', on_delete=django.db.models.deletion.CASCADE, to='aldryn_newsblog.NewsBlogConfig', verbose_name='Section'),
),
migrations.AlterField(
model_name='article',
name='featured_image',
field=filer.fields.image.FilerImageField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.FILER_IMAGE_MODEL, verbose_name='featured image'),
),
migrations.AlterField(
model_name='newsblogconfig',
name='namespace',
field=models.CharField(default=None, max_length=100, unique=True, verbose_name='Instance namespace'),
),
migrations.AlterField(
model_name='newsblogconfig',
name='template_prefix',
field=models.CharField(blank=True, choices=TEMPLATE_PREFIX_CHOICES, max_length=20, null=True, verbose_name='Prefix for template dirs'),
),
migrations.AlterField(
model_name='newsblogconfig',
name='type',
field=models.CharField(max_length=100, verbose_name='Type'),
),
migrations.AlterField(
model_name='newsblogconfigtranslation',
name='app_title',
field=models.CharField(max_length=234, verbose_name='name'),
),
]
29 changes: 23 additions & 6 deletions aldryn_newsblog/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
from cms.appresolver import clear_app_resolvers
from cms.exceptions import AppAlreadyRegistered
from cms.test_utils.testcases import CMSTestCase, TransactionCMSTestCase
from cms.utils.conf import get_cms_setting

from cms.toolbar.toolbar import CMSToolbar

from cms.utils.conf import get_cms_setting

from parler.utils.context import switch_language

Expand Down Expand Up @@ -185,9 +183,23 @@ def setUp(self):
self.template = get_cms_setting('TEMPLATES')[0][0]
self.language = settings.LANGUAGES[0][0]
self.root_page = api.create_page(
'root page', self.template, self.language, published=True)
self.app_config = NewsBlogConfig.objects.create(
namespace='NBNS', paginate_by=15)
'root page',
self.template,
self.language,
published=True,
)

try:
# Django-cms 3.5 doesn't set is_home when create_page is called
self.root_page.set_as_homepage()
except AttributeError:
pass

self.app_config = NewsBlogConfig.objects.language(self.language).create(
app_title='news_blog',
namespace='NBNS',
paginate_by=15,
)
self.page = api.create_page(
'page', self.template, self.language, published=True,
parent=self.root_page,
Expand All @@ -209,6 +221,11 @@ def setUp(self):
class CleanUpMixin(object):
apphook_object = None

def setUp(self):
super(CleanUpMixin, self).setUp()
apphook_object = self.get_apphook_object()
self.reload_urls(apphook_object)

def tearDown(self):
"""
Do a proper cleanup, delete everything what is preventing us from
Expand Down
8 changes: 5 additions & 3 deletions aldryn_newsblog/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def test_admin_owner_default(self):
self.request.user = user
self.request.META['HTTP_HOST'] = 'example.com'
response = admin_inst.add_view(self.request)
option = '<option value="1" selected="selected">%s</option>'
self.assertContains(response, option % user.username)
self.assertContains(response, option % user.get_full_name())
option = r'<option value="{}" (selected="selected"|selected)>%s<\/option>'.format(
user.pk,
)
self.assertRegexpMatches(response.rendered_content, option % user.username)
self.assertRegexpMatches(response.rendered_content, option % user.get_full_name())
11 changes: 7 additions & 4 deletions aldryn_newsblog/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,16 @@ def test_featured_articles_plugin(self):
self.assertNotContains(response, article.title)

def test_featured_articles_plugin_unpublished_app_page(self):
with override('de'):
with override(self.language):
articles = [self.create_article(is_featured=True)
for _ in range(3)]

response = self.client.get(self.plugin_page.get_absolute_url())
for article in articles:
self.assertContains(response, article.title)

self.page.unpublish('de')
self.page.unpublish(self.language)
self.reload_urls()
cache.clear()
response = self.client.get(self.plugin_page.get_absolute_url())
for article in articles:
Expand Down Expand Up @@ -294,14 +295,15 @@ def test_latest_articles_plugin_no_excluded_featured(self):
self._test_latest_articles_plugin_exclude_count()

def test_latest_articles_plugin_unpublished_app_page(self):
with override('de'):
with override(self.language):
articles = [self.create_article() for _ in range(3)]

response = self.client.get(self.plugin_page.get_absolute_url())
for article in articles:
self.assertContains(response, article.title)

self.page.unpublish('de')
self.page.unpublish(self.language)
self.reload_urls()
cache.clear()
response = self.client.get(self.plugin_page.get_absolute_url())
for article in articles:
Expand Down Expand Up @@ -372,6 +374,7 @@ def test_related_articles_plugin(self):
self.assertNotContains(response, article.title)

self.page.unpublish('de')
self.reload_urls()
cache.clear()
response = self.client.get(main_article.get_absolute_url())
for article in another_language_articles:
Expand Down
3 changes: 3 additions & 0 deletions aldryn_newsblog/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def test_article_is_indexed_using_prepare(self):
lead_in = 'Hello! this text will be searchable.'

article = self.create_article(lead_in=lead_in)
# If set ALDRYN_NEWSBLOG_UPDATE_SEARCH_DATA_ON_SAVE this will do
# automatically
article.search_data = article.get_search_data()

index = self.get_index()

Expand Down
1 change: 1 addition & 0 deletions aldryn_newsblog/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ def test_index_simple(self):
article.tags.add(tag_name)
for category in (self.category1, self.category2):
article.categories.add(category)
article.update_search_on_save = True
article.save()

self.assertEqual(self.index.get_title(article), 'a title')
Expand Down
24 changes: 14 additions & 10 deletions aldryn_newsblog/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from django.contrib.sites.models import get_current_site
from django.core.urlresolvers import reverse, NoReverseMatch
from django.db import models
from django.template import RequestContext
from django.test import RequestFactory
from django.utils import translation
try:
Expand All @@ -22,6 +21,7 @@
from django.utils.html import strip_tags as _strip_tags
from django.utils.text import smart_split

from cms.plugin_rendering import ContentRenderer
from cms.utils.i18n import force_language, get_language_object

from lxml.html.clean import Cleaner as LxmlCleaner
Expand Down Expand Up @@ -109,20 +109,26 @@ def get_field_value(obj, name):
return value


def render_plugin(request, plugin_instance):
renderer = ContentRenderer(request)
context = {'request': request}
return renderer.render_plugin(plugin_instance, context)


def get_plugin_index_data(base_plugin, request):
text_bits = []

instance, plugin_type = base_plugin.get_plugin_instance()
plugin_instance, plugin_type = base_plugin.get_plugin_instance()

if instance is None:
if plugin_instance is None:
# this is an empty plugin
return text_bits

search_fields = getattr(instance, 'search_fields', [])
search_fields = getattr(plugin_instance, 'search_fields', [])

if hasattr(instance, 'search_fulltext'):
if hasattr(plugin_instance, 'search_fulltext'):
# check if the plugin instance has search enabled
search_contents = instance.search_fulltext
search_contents = plugin_instance.search_fulltext
elif hasattr(base_plugin, 'search_fulltext'):
# now check in the base plugin instance (CMSPlugin)
search_contents = base_plugin.search_fulltext
Expand All @@ -135,13 +141,11 @@ def get_plugin_index_data(base_plugin, request):
search_contents = not bool(search_fields)

if search_contents:
plugin_contents = instance.render_plugin(
context=RequestContext(request))

plugin_contents = render_plugin(request, plugin_instance)
if plugin_contents:
text_bits = get_cleaned_bits(plugin_contents)
else:
values = (get_field_value(instance, field) for field in search_fields)
values = (get_field_value(plugin_instance, field) for field in search_fields)

for value in values:
cleaned_bits = get_cleaned_bits(value or '')
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
from aldryn_newsblog import __version__

REQUIREMENTS = [
'Django>=1.8,<1.11',
'Django>=1.8,<2.0',
'python-dateutil',
'aldryn-apphooks-config>=0.2.4',
'aldryn-apphooks-config>=0.4.0',
'aldryn-boilerplates>=0.7.2',
'aldryn-categories>=1.1.0',
'aldryn-common>=0.1.3',
'aldryn-people>=1.1.0',
'aldryn-translation-tools>=0.2.0',
'backport_collections==0.1',
'django-appdata>=0.1.4',
'django-cms>=3.2',
'django-cms>=3.4',
'djangocms-text-ckeditor',
'django-filer>=0.9.9',
'django-parler>=1.4',
Expand All @@ -30,19 +30,19 @@
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.6',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: News/Diary',
'Topic :: Software Development',
Expand Down

0 comments on commit 9c43b39

Please sign in to comment.