Add visit count and days to segment overview
This commit is contained in:
27
src/personalisation/migrations/0017_auto_20161109_1435.py
Normal file
27
src/personalisation/migrations/0017_auto_20161109_1435.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.3 on 2016-11-09 13:35
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('personalisation', '0016_auto_20161109_1255'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='segment',
|
||||||
|
name='create_date',
|
||||||
|
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='segment',
|
||||||
|
name='edit_date',
|
||||||
|
field=models.DateTimeField(auto_now=True),
|
||||||
|
),
|
||||||
|
]
|
20
src/personalisation/migrations/0018_segment_visit_count.py
Normal file
20
src/personalisation/migrations/0018_segment_visit_count.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.3 on 2016-11-09 14:29
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('personalisation', '0017_auto_20161109_1435'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='segment',
|
||||||
|
name='visit_count',
|
||||||
|
field=models.PositiveIntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
@ -6,18 +6,18 @@ from datetime import datetime
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from modelcluster.fields import ParentalKey
|
|
||||||
from modelcluster.models import ClusterableModel
|
from modelcluster.models import ClusterableModel
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
||||||
from wagtail.wagtailcore.models import Orderable
|
|
||||||
|
|
||||||
from polymorphic.models import PolymorphicModel
|
from polymorphic.models import PolymorphicModel
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Segment(ClusterableModel):
|
class Segment(ClusterableModel):
|
||||||
"""Model for a new segment"""
|
"""Model for a new segment"""
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
create_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
edit_date = models.DateTimeField(auto_now=True)
|
||||||
|
visit_count = models.PositiveIntegerField(default=0)
|
||||||
STATUS_CHOICES = (
|
STATUS_CHOICES = (
|
||||||
('enabled', 'Enabled'),
|
('enabled', 'Enabled'),
|
||||||
('disabled', 'Disabled'),
|
('disabled', 'Disabled'),
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 794 B |
@ -64,6 +64,38 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.block_container .block .segment_stats {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block_container .block .segment_stats li {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-right: 50px;
|
||||||
|
}
|
||||||
|
.block_container .block .segment_stats li::last-child{
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block_container .block .segment_stats li::before {
|
||||||
|
display: inline-block;
|
||||||
|
content: "";
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin-right: 5px;
|
||||||
|
background-size: 20px 20px;
|
||||||
|
}
|
||||||
|
.block_container .block .segment_stats .visit_stat::before {
|
||||||
|
background-image: url("./rocket_icon.png");
|
||||||
|
}
|
||||||
|
.block_container .block .segment_stats .days_stat::before {
|
||||||
|
background-image: url("./calendar_icon.png");
|
||||||
|
}
|
||||||
|
|
||||||
.block_container .block.suggestion .suggestive_text {
|
.block_container .block.suggestion .suggestive_text {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -75,3 +107,7 @@
|
|||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.block_container .block.suggestion .suggestive_text:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -1,5 +1,5 @@
|
|||||||
{% extends "modeladmin/index.html" %}
|
{% extends "modeladmin/index.html" %}
|
||||||
{% load i18n staticfiles modeladmin_tags %}
|
{% load i18n staticfiles modeladmin_tags personalisation_filters %}
|
||||||
|
|
||||||
{% block content_main %}
|
{% block content_main %}
|
||||||
<div>
|
<div>
|
||||||
@ -23,6 +23,10 @@
|
|||||||
{% for segment in object_list %}
|
{% for segment in object_list %}
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<a href="inspect/{{ segment.pk }}"><h2>{{ segment }}</h2></a>
|
<a href="inspect/{{ segment.pk }}"><h2>{{ segment }}</h2></a>
|
||||||
|
<ul class="segment_stats">
|
||||||
|
<li class="visit_stat">{{ segment.visit_count }}</li>
|
||||||
|
<li class="days_stat">{{ segment.create_date|days_since:segment.status }}</li>
|
||||||
|
</ul>
|
||||||
{% if user_can_create %}
|
{% if user_can_create %}
|
||||||
<ul class="block_actions">
|
<ul class="block_actions">
|
||||||
{% if segment.status == "disabled" %}
|
{% if segment.status == "disabled" %}
|
||||||
|
0
src/personalisation/templatetags/__init__.py
Normal file
0
src/personalisation/templatetags/__init__.py
Normal file
13
src/personalisation/templatetags/personalisation_filters.py
Normal file
13
src/personalisation/templatetags/personalisation_filters.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from django.template import Library
|
||||||
|
|
||||||
|
register = Library()
|
||||||
|
|
||||||
|
@register.filter(name='days_since')
|
||||||
|
def active_days(value, arg):
|
||||||
|
"""Returns the number of days the segment has been active"""
|
||||||
|
if arg == 'enabled':
|
||||||
|
delta = timezone.now() - value
|
||||||
|
return delta.days
|
||||||
|
return 0
|
@ -1,5 +1,6 @@
|
|||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
|
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
|
||||||
|
from wagtail.contrib.modeladmin.views import IndexView
|
||||||
from wagtail.wagtailcore import hooks
|
from wagtail.wagtailcore import hooks
|
||||||
|
|
||||||
from personalisation import admin_urls
|
from personalisation import admin_urls
|
||||||
@ -22,10 +23,10 @@ class SegmentModelAdmin(ModelAdmin):
|
|||||||
model = Segment
|
model = Segment
|
||||||
menu_icon = 'group'
|
menu_icon = 'group'
|
||||||
add_to_settings_menu = False
|
add_to_settings_menu = False
|
||||||
list_display = ('status', 'name')
|
list_display = ('status', 'name', 'create_date', 'edit_date')
|
||||||
inspect_view_enabled = True
|
|
||||||
index_view_extra_css = ['personalisation/segment/index.css']
|
index_view_extra_css = ['personalisation/segment/index.css']
|
||||||
form_view_extra_css = ['personalisation/segment/form.css']
|
form_view_extra_css = ['personalisation/segment/form.css']
|
||||||
|
inspect_view_enabled = True
|
||||||
|
|
||||||
modeladmin_register(SegmentModelAdmin)
|
modeladmin_register(SegmentModelAdmin)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user