Adds variant count
This commit is contained in:
committed by
Michael van Tellingen
parent
cb03a36ba2
commit
961a58505a
@ -79,6 +79,16 @@ class Segment(ClusterableModel):
|
||||
"""Return the amount of days the segment has been active."""
|
||||
return count_active_days(self.enable_date, self.disable_date)
|
||||
|
||||
def get_used_pages(self):
|
||||
pass
|
||||
|
||||
def get_created_variants(self):
|
||||
page_classes = [page_class for page_class
|
||||
in PersonalisablePage.__subclasses__()]
|
||||
pages = [page.objects.filter(segment=self) for page in page_classes]
|
||||
|
||||
return list(itertools.chain(*pages))
|
||||
|
||||
def get_rules(self):
|
||||
"""Retrieve all rules in the segment."""
|
||||
related_rules = [rule.objects.filter(segment=self)
|
||||
|
@ -39,7 +39,7 @@ class SegmentModelAdmin(ModelAdmin):
|
||||
dashboard_view_class = SegmentModelDashboardView
|
||||
menu_icon = 'fa-snowflake-o'
|
||||
add_to_settings_menu = False
|
||||
list_display = ('name', 'persistent', 'match_any', 'status', 'statistics')
|
||||
list_display = ('name', 'persistent', 'match_any', 'status', 'variant_count', 'statistics')
|
||||
index_view_extra_js = ['js/commons.js', 'js/index.js']
|
||||
index_view_extra_css = ['css/index.css']
|
||||
form_view_extra_js = ['js/commons.js', 'js/form.js']
|
||||
@ -55,6 +55,10 @@ class SegmentModelAdmin(ModelAdmin):
|
||||
|
||||
return view_class.as_view(**kwargs)(request)
|
||||
|
||||
def variant_count(self, obj):
|
||||
return _("{pages} pages").format(
|
||||
pages=len(obj.get_created_variants()))
|
||||
|
||||
def statistics(self, obj):
|
||||
return _("{visits} visits in {days} days").format(
|
||||
visits=obj.visit_count, days=obj.get_active_days())
|
||||
|
Reference in New Issue
Block a user