fixes a few future imports and adds support for new python and wagtail versions
This commit is contained in:
13
setup.py
13
setup.py
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
|
|||||||
|
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'wagtail>=1.7',
|
'wagtail<=1.10',
|
||||||
'user-agents>=1.0.1',
|
'user-agents>=1.0.1',
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -16,6 +16,10 @@ tests_require = [
|
|||||||
'wagtail_factories==0.2.0',
|
'wagtail_factories==0.2.0',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
docs_require = [
|
||||||
|
'sphinx>=1.4.0',
|
||||||
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='wagtail-personalisation',
|
name='wagtail-personalisation',
|
||||||
version='0.1.0',
|
version='0.1.0',
|
||||||
@@ -26,6 +30,7 @@ setup(
|
|||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
extras_require={
|
extras_require={
|
||||||
|
'docs': docs_require,
|
||||||
'test': tests_require,
|
'test': tests_require,
|
||||||
},
|
},
|
||||||
packages=find_packages('src'),
|
packages=find_packages('src'),
|
||||||
@@ -39,13 +44,17 @@ setup(
|
|||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: BSD License',
|
'License :: OSI Approved :: BSD License',
|
||||||
'Operating System :: OS Independent',
|
'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.4',
|
||||||
'Programming Language :: Python :: 3.5',
|
'Programming Language :: Python :: 3.5',
|
||||||
|
'Programming Language :: Python :: 3.6',
|
||||||
'Framework :: Django',
|
'Framework :: Django',
|
||||||
'Framework :: Django :: 1.8',
|
'Framework :: Django :: 1.8',
|
||||||
'Framework :: Django :: 1.9',
|
'Framework :: Django :: 1.9',
|
||||||
'Framework :: Django :: 1.10',
|
'Framework :: Django :: 1.10',
|
||||||
|
'Framework :: Django :: 1.11',
|
||||||
'Topic :: Internet :: WWW/HTTP :: Site Management',
|
'Topic :: Internet :: WWW/HTTP :: Site Management',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import absolute_import, unicode_literals
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
|
@@ -1,24 +1,22 @@
|
|||||||
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
from wagtail.wagtailcore import blocks
|
from wagtail.wagtailcore import blocks
|
||||||
from personalisation.models import Segment
|
from personalisation.models import Segment
|
||||||
|
|
||||||
|
|
||||||
def list_segment_choices():
|
def list_segment_choices():
|
||||||
|
|
||||||
for s in Segment.objects.all():
|
for s in Segment.objects.all():
|
||||||
yield (s.pk, s.name)
|
yield (s.pk, s.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PersonalisedStructBlock(blocks.StructBlock):
|
class PersonalisedStructBlock(blocks.StructBlock):
|
||||||
|
|
||||||
segment = blocks.ChoiceBlock(
|
segment = blocks.ChoiceBlock(
|
||||||
choices=list_segment_choices,
|
choices=list_segment_choices,
|
||||||
required=False, label="Personalisation segment",
|
required=False, label=_("Personalisation segment"),
|
||||||
help_text="Only show this content block for users in this segment")
|
help_text=_("Only show this content block for users in this segment"))
|
||||||
|
|
||||||
|
|
||||||
def render(self, value, context=None):
|
def render(self, value, context=None):
|
||||||
"""Only render this content block for users in this segment"""
|
"""Only render this content block for users in this segment"""
|
||||||
|
|
||||||
# TODO: move logic to its own class instead of getting it from the session
|
# TODO: move logic to its own class instead of getting it from the session
|
||||||
user_segments = context['request'].session['segments']
|
user_segments = context['request'].session['segments']
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user