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()
@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 '-'
<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 %}
<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"