Commit 66a47c30 authored by fred's avatar fred

misc: display number of "visits" (play) of a sound

parent be628a66
from django.template import Library
from django.conf import settings
from django.core.urlresolvers import reverse
from django.db.models import Sum
from emissions.models import Emission, Episode, NewsItem, SoundFile, Focus
from panikombo.models import Topik
from panikdb.stats.models import DailyStat
from combo.data.models import Page
register = Library()
......@@ -136,3 +138,8 @@ def has_topik(obj):
@register.filter
def topik_id(obj):
return Topik.objects.get(page=obj).id
@register.filter
def nb_visits(obj):
t = DailyStat.objects.filter(soundfile_id=obj.id).aggregate(Sum('nb_visits'))
return t['nb_visits__sum'] or '-'
......@@ -78,6 +78,7 @@ Tags :
<th>Format</th>
<th>Podcastable?</th>
<th>Fragment?</th>
<th>Nb d'écoutes</th>
{% if can_manage %}<th>Modifier</th>{% endif %}
{% if can_manage %}<th>Supprimer</th>{% endif %}
{% if perms.emissions.add_focus %}<th>Focus</th>{% endif %}
......@@ -91,6 +92,7 @@ Tags :
<td>{% if soundfile.format %}{{ soundfile.format }}{% else %}-{% endif %}</td>
<td>{% if soundfile.podcastable %}oui{% else %}non{% endif %}</td>
<td>{% if soundfile.fragment %}oui{% else %}non{% endif %}</td>
<td>{{ soundfile|nb_visits }}</td>
{% if can_manage %}<td><a href="sounds/{{ soundfile.id }}/"
class="icon-edit" title="Modifier"></a></td>{% endif %}
{% if can_manage %}<td><a href="sounds/{{ soundfile.id }}/remove"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment