adds a few docblocks and isorts
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import time
|
||||
|
||||
from django.db.models import F
|
||||
@ -43,6 +44,9 @@ class BaseSegmentsAdapter(object):
|
||||
|
||||
|
||||
class SessionSegmentsAdapter(BaseSegmentsAdapter):
|
||||
"""
|
||||
Segment adapter that uses Django's session backend.
|
||||
"""
|
||||
def setup(self, request):
|
||||
self.request = request
|
||||
|
||||
@ -96,4 +100,3 @@ class SessionSegmentsAdapter(BaseSegmentsAdapter):
|
||||
self.request.session['segments'] = new_segments
|
||||
|
||||
update_visit_count(self)
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
from django.conf import settings
|
||||
from django.utils.module_loading import import_string
|
||||
|
||||
|
||||
segments_adapter = import_string(getattr(settings, 'PERSONALISATION_SEGMENTS_ADAPTER', 'personalisation.adapters.SessionSegmentsAdapter'))()
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from wagtail.wagtailcore import blocks
|
||||
|
||||
from personalisation.models import Segment
|
||||
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
# Generated by Django 1.10.1 on 2016-12-11 12:15
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import modelcluster.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -2,9 +2,9 @@
|
||||
# Generated by Django 1.10.5 on 2017-01-10 14:35
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import modelcluster.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -2,9 +2,9 @@
|
||||
# Generated by Django 1.10.7 on 2017-04-20 15:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import modelcluster.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -2,13 +2,13 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import re
|
||||
from datetime import datetime
|
||||
from user_agents import parse
|
||||
|
||||
from django.db import models
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from modelcluster.fields import ParentalKey
|
||||
from user_agents import parse
|
||||
from wagtail.wagtailadmin.edit_handlers import (
|
||||
FieldPanel, FieldRowPanel, PageChooserPanel)
|
||||
|
||||
|
@ -1,6 +1,13 @@
|
||||
import time
|
||||
|
||||
|
||||
def impersonate_other_page(page, other_page):
|
||||
"""
|
||||
Function to change the page metadata so the user gets to see the
|
||||
non-personalized path and page.
|
||||
:param page: The page to be impersonated
|
||||
:param other_page: The page it should impersonate
|
||||
"""
|
||||
page.path = other_page.path
|
||||
page.depth = other_page.depth
|
||||
page.url_path = other_page.url_path
|
||||
@ -8,6 +15,12 @@ def impersonate_other_page(page, other_page):
|
||||
|
||||
|
||||
def create_segment_dictionary(segment):
|
||||
"""
|
||||
Creates a dictionary with all the required segment
|
||||
information.
|
||||
:param segment: Segment object
|
||||
:return: Dictionary with name, id, timestamp and persistent state.
|
||||
"""
|
||||
return {
|
||||
"encoded_name": segment.encoded_name(),
|
||||
"id": segment.pk,
|
||||
|
@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, reverse
|
||||
|
||||
from personalisation.models import PersonalisablePage, Segment
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
import factory
|
||||
|
||||
from personalisation import rules
|
||||
@ -45,4 +46,3 @@ class VisitCountRuleFactory(factory.DjangoModelFactory):
|
||||
|
||||
class Meta:
|
||||
model = rules.VisitCountRule
|
||||
|
||||
|
@ -6,12 +6,10 @@ import pytest
|
||||
|
||||
from personalisation.models import Segment
|
||||
from personalisation.rules import TimeRule
|
||||
|
||||
from tests.factories.segment import SegmentFactory
|
||||
from tests.factories.rule import (
|
||||
QueryRuleFactory, ReferralRuleFactory, TimeRuleFactory,
|
||||
DayRuleFactory, VisitCountRuleFactory, DeviceRuleFactory)
|
||||
|
||||
DayRuleFactory, DeviceRuleFactory, QueryRuleFactory, ReferralRuleFactory,
|
||||
TimeRuleFactory, VisitCountRuleFactory)
|
||||
from tests.factories.segment import SegmentFactory
|
||||
|
||||
"""Factory tests"""
|
||||
@pytest.mark.django_db
|
||||
|
@ -8,10 +8,10 @@ from freezegun import freeze_time
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail_factories import SiteFactory
|
||||
|
||||
from tests.factories.segment import SegmentFactory
|
||||
from tests.factories.rule import (
|
||||
QueryRuleFactory, ReferralRuleFactory, TimeRuleFactory,
|
||||
DayRuleFactory, VisitCountRuleFactory, DeviceRuleFactory)
|
||||
DayRuleFactory, DeviceRuleFactory, QueryRuleFactory, ReferralRuleFactory,
|
||||
TimeRuleFactory, VisitCountRuleFactory)
|
||||
from tests.factories.segment import SegmentFactory
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
Reference in New Issue
Block a user