Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add naturaltime for active segments #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ To install the package with pip::

pip install wagtail-personalisation

Next, include the ``wagtail_personalisation`` and
``wagtail.contrib.modeladmin`` app in your project's ``INSTALLED_APPS``:
Next, add the required apps in your ``INSTALLED_APPS`` setting:

.. code-block:: python

INSTALLED_APPS = [
# ...
# Required apps
'django.contrib.humanize',
'wagtail.contrib.modeladmin',
'wagtail_personalisation',
# ...
]

Make sure that ``django.contrib.sessions.middleware.SessionMiddleware`` has
Expand Down
6 changes: 3 additions & 3 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ The Wagxperience app runs in the Wagtail CMS. You can find out more here_.

pip install wagtail-personalisation

2. Add the module and ``wagtail.contrib.modeladmin`` to your ``INSTALLED_APPS``::
2. Add the required apps in your ``INSTALLED_APPS`` setting::

INSTALLED_APPS = [
# ...
# Required apps
'django.contrib.humanize',
'wagtail.contrib.modeladmin',
'wagtail_personalisation',
# ...
]

3. Update your database::
Expand Down
1 change: 1 addition & 0 deletions sandbox/sandbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
Expand Down
7 changes: 4 additions & 3 deletions src/wagtail_personalisation/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime

from django.db import models
from django.template.defaultfilters import slugify
from django.template.defaultfilters import pluralize, slugify
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from modelcluster.fields import ParentalKey
Expand Down Expand Up @@ -251,9 +251,10 @@ def description(self):
'title': _('These users visited {}').format(
self.counted_page
),
'value': _('{} {} times').format(
'value': _('{} {} time{}').format(
self.get_operator_display(),
self.count
self.count,
pluralize(self.count)
),
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "modeladmin/wagtail_personalisation/segment/base.html" %}
{% load i18n l10n staticfiles modeladmin_tags wagtail_personalisation_filters %}
{% load humanize i18n l10n staticfiles modeladmin_tags wagtail_personalisation_filters %}

{% block toggle_view %}to List {% endblock%}

Expand Down Expand Up @@ -31,8 +31,8 @@ <h2>{{ segment }}</h2>
<span>{{ segment.visit_count|localize }} {% trans "time" %}{{ segment.visit_count|pluralize }}</span>
</li>
<li class="days_stat">
{% trans "This segment has been active for" %}
<span>{{ segment.enable_date|days_since:segment.disable_date }} {% trans "day" %}{{ segment.enable_date|days_since:segment.disable_date|pluralize }}</span>
{% trans "This segment has been active since" %}
<span>{{ segment.enable_date|naturaltime }}</span>
</li>
</ul>

Expand Down
1 change: 1 addition & 0 deletions tests/sandbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
Expand Down