From 82d11d57aa2302f44a572002abf521e0ade4526f Mon Sep 17 00:00:00 2001 From: blurrah Date: Wed, 3 May 2017 08:58:05 +0200 Subject: [PATCH] fixes a few future imports and adds support for new python and wagtail versions --- setup.py | 13 +++++++++++-- src/personalisation/adapters.py | 1 + src/personalisation/blocks.py | 12 +++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 96809c9..b70e98a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import find_packages, setup install_requires = [ - 'wagtail>=1.7', + 'wagtail<=1.10', 'user-agents>=1.0.1', ] @@ -16,6 +16,10 @@ tests_require = [ 'wagtail_factories==0.2.0', ] +docs_require = [ + 'sphinx>=1.4.0', +] + setup( name='wagtail-personalisation', version='0.1.0', @@ -26,6 +30,7 @@ setup( install_requires=install_requires, tests_require=tests_require, extras_require={ + 'docs': docs_require, 'test': tests_require, }, packages=find_packages('src'), @@ -39,13 +44,17 @@ setup( 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', - 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Framework :: Django', 'Framework :: Django :: 1.8', 'Framework :: Django :: 1.9', 'Framework :: Django :: 1.10', + 'Framework :: Django :: 1.11', 'Topic :: Internet :: WWW/HTTP :: Site Management', ], ) diff --git a/src/personalisation/adapters.py b/src/personalisation/adapters.py index da3be64..0b3e8a0 100644 --- a/src/personalisation/adapters.py +++ b/src/personalisation/adapters.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import, unicode_literals import time from django.db.models import F diff --git a/src/personalisation/blocks.py b/src/personalisation/blocks.py index 09dffee..b5fa739 100644 --- a/src/personalisation/blocks.py +++ b/src/personalisation/blocks.py @@ -1,24 +1,22 @@ +from __future__ import absolute_import, unicode_literals + from wagtail.wagtailcore import blocks from personalisation.models import Segment + def list_segment_choices(): - for s in Segment.objects.all(): yield (s.pk, s.name) - class PersonalisedStructBlock(blocks.StructBlock): - segment = blocks.ChoiceBlock( choices=list_segment_choices, - required=False, label="Personalisation segment", - help_text="Only show this content block for users in this segment") - + required=False, label=_("Personalisation segment"), + help_text=_("Only show this content block for users in this segment")) def render(self, value, context=None): """Only render this content block for users in this segment""" - # TODO: move logic to its own class instead of getting it from the session user_segments = context['request'].session['segments']