7

Codestyle fixes (flake8)

This also adds the flake8 dependencies to the test extras for
installation.
This commit is contained in:
Michael van Tellingen
2017-05-28 09:13:08 +02:00
parent 55da67523f
commit 3eac2cd4dd
21 changed files with 123 additions and 114 deletions

View File

@ -36,10 +36,10 @@ class AbstractBaseRule(models.Model):
def description(self):
"""Return a description explaining the functionality of the rule.
Used in the segmentation dashboard.
:returns: A dict containing a title and a value
:rtype: dict
"""
description = {
'title': _('Abstract segmentation rule'),
@ -55,10 +55,10 @@ class AbstractBaseRule(models.Model):
@python_2_unicode_compatible
class TimeRule(AbstractBaseRule):
"""Time rule to segment users based on a start and end time.
Matches when the time a request is made falls between the
set start time and end time.
"""
start_time = models.TimeField(_("Starting time"))
end_time = models.TimeField(_("Ending time"))
@ -98,10 +98,10 @@ class TimeRule(AbstractBaseRule):
@python_2_unicode_compatible
class DayRule(AbstractBaseRule):
"""Day rule to segment users based on the day(s) of a visit.
Matches when the day a request is made matches with the days
set in the rule.
"""
mon = models.BooleanField(_("Monday"), default=False)
tue = models.BooleanField(_("Tuesday"), default=False)
@ -159,10 +159,10 @@ class DayRule(AbstractBaseRule):
@python_2_unicode_compatible
class ReferralRule(AbstractBaseRule):
"""Referral rule to segment users based on a regex test.
Matches when the referral header in a request matches with
the set regex test.
"""
regex_string = models.TextField(
_("Regex string to match the referer with"))
@ -202,10 +202,10 @@ class ReferralRule(AbstractBaseRule):
class VisitCountRule(AbstractBaseRule):
"""Visit count rule to segment users based on amount of visits to a
specified page.
Matches when the operator and count validate True
when visiting the set page.
"""
OPERATOR_CHOICES = (
('more_than', _("More than")),
@ -241,13 +241,13 @@ class VisitCountRule(AbstractBaseRule):
def get_visit_count(request):
"""Search through the request sessions to get the page visit count
corresponding to the request.
:param request: The http request
:type request: django.http.HttpRequest
:returns: A number indicating the amount of visits
to the requested page
:rtype: int
"""
for page in request.session['visit_count']:
if page['path'] == request.path:
@ -286,10 +286,10 @@ class VisitCountRule(AbstractBaseRule):
@python_2_unicode_compatible
class QueryRule(AbstractBaseRule):
"""Query rule to segment users based on matching queries.
Matches when both the set parameter and value match with one
present in the request query.
"""
parameter = models.SlugField(_("The query parameter to search for"),
max_length=20)
@ -332,10 +332,10 @@ class QueryRule(AbstractBaseRule):
@python_2_unicode_compatible
class DeviceRule(AbstractBaseRule):
"""Device rule to segment users based on matching devices.
Matches when the set device type matches with the one present
in the request user agent headers.
"""
mobile = models.BooleanField(_("Mobile phone"), default=False)
tablet = models.BooleanField(_("Tablet"), default=False)
@ -371,9 +371,9 @@ class DeviceRule(AbstractBaseRule):
class UserIsLoggedInRule(AbstractBaseRule):
"""User is logged in rule to segment users based on their authentication
status.
Matches when the user is authenticated.
"""
is_logged_in = models.BooleanField(default=False)