7

Compare commits

..

5 Commits

Author SHA1 Message Date
82c26f9772 Merge branch 'release/0.11.3' 2018-03-09 20:35:20 +02:00
03eb812e45 Version 0.11.3 2018-03-09 20:35:08 +02:00
e3522d0acb Merge pull request #26 from praekeltfoundation/feature/catch-exceptions-when-visit-count-rule-is-blank
Handle exceptions for empty VisitCountRule
2018-03-09 20:32:05 +02:00
7f5e958ee3 Catch the exception if the visit count rule doesn't have a page 2018-03-09 19:20:30 +02:00
241bfb5240 Merge tag '0.11.2' into develop
Bugfix: Stop populating static segments when the count is reached
2018-03-08 14:00:58 +02:00
6 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,7 @@
0.11.3
==================
- Bugfix: Handle errors when testing an invalid visit count rule
0.11.2 0.11.2
================== ==================
- Bugfix: Stop populating static segments when the count is reached - Bugfix: Stop populating static segments when the count is reached

View File

@ -55,10 +55,10 @@ author = 'Lab Digital BV'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.11.2' version = '0.11.3'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.11.2' release = '0.11.3'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -1,5 +1,5 @@
[bumpversion] [bumpversion]
current_version = 0.11.2 current_version = 0.11.3
commit = true commit = true
tag = true tag = true
tag_name = {new_version} tag_name = {new_version}

View File

@ -32,7 +32,7 @@ with open('README.rst') as fh:
setup( setup(
name='wagtail-personalisation-molo', name='wagtail-personalisation-molo',
version='0.11.2', version='0.11.3',
description='A forked version of Wagtail add-on for showing personalized content', description='A forked version of Wagtail add-on for showing personalized content',
author='Praekelt.org', author='Praekelt.org',
author_email='dev@praekeltfoundation.org', author_email='dev@praekeltfoundation.org',

View File

@ -6,6 +6,7 @@ from importlib import import_module
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.sessions.models import Session from django.contrib.sessions.models import Session
from django.db import models from django.db import models
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
@ -239,6 +240,12 @@ class VisitCountRule(AbstractBaseRule):
from wagtail_personalisation.adapters import ( from wagtail_personalisation.adapters import (
get_segment_adapter, SessionSegmentsAdapter, SEGMENT_ADAPTER_CLASS) get_segment_adapter, SessionSegmentsAdapter, SEGMENT_ADAPTER_CLASS)
# Django formsets don't honour 'required' fields so check rule is valid
try:
self.counted_page
except ObjectDoesNotExist:
return False
if user: if user:
# Create a fake request so we can use the adapter # Create a fake request so we can use the adapter
request = RequestFactory().get('/') request = RequestFactory().get('/')

View File

@ -2,6 +2,7 @@ import pytest
from tests.factories.rule import VisitCountRuleFactory from tests.factories.rule import VisitCountRuleFactory
from tests.factories.segment import SegmentFactory from tests.factories.segment import SegmentFactory
from wagtail_personalisation.rules import VisitCountRule
@pytest.mark.django_db @pytest.mark.django_db
@ -25,6 +26,12 @@ def test_visit_count(site, client):
assert visit_count[1]['count'] == 1 assert visit_count[1]['count'] == 1
@pytest.mark.django_db
def test_call_test_user_on_invalid_rule_fails(site, user, mocker):
rule = VisitCountRule()
assert not (rule.test_user(None, user))
@pytest.mark.django_db @pytest.mark.django_db
def test_visit_count_call_test_user_with_user(site, client, user): def test_visit_count_call_test_user_with_user(site, client, user):
segment = SegmentFactory(name='VisitCount') segment = SegmentFactory(name='VisitCount')