Compare commits
5 Commits
master
...
95a847cee0
Author | SHA1 | Date | |
---|---|---|---|
95a847cee0 | |||
8281c1a4c9 | |||
efd940f34f | |||
893f441ddd | |||
cd76659ed9 |
@ -30,7 +30,7 @@ class AdminSite(admin.AdminSite):
|
||||
'programs': Program.objects.active().values('pk', 'title') \
|
||||
.order_by('title'),
|
||||
# today's diffusions
|
||||
'diffusions': Diffusion.objects.on_air().date().order_by('start') \
|
||||
'diffusions': Diffusion.objects.date().order_by('start') \
|
||||
.select_related('episode'),
|
||||
# TODO: only for dashboard
|
||||
# last comments
|
||||
|
@ -252,7 +252,7 @@ class Diffusion(BaseRerun):
|
||||
return self.type == self.TYPE_ON_AIR and \
|
||||
self.start <= now and self.end >= now
|
||||
|
||||
# TODO: property?
|
||||
@property
|
||||
def is_live(self):
|
||||
""" True if Diffusion is live (False if there are sounds files). """
|
||||
return self.type == self.TYPE_ON_AIR and \
|
||||
|
@ -16,7 +16,31 @@
|
||||
<tr {% if diffusion.is_now %}class="is-selected"{% endif %}>
|
||||
<td>{{ diffusion.start|time }} - {{ diffusion.end|time }}</td>
|
||||
<td><img src="{% thumbnail episode.cover 64x64 crop %}"/></td>
|
||||
<td><a href="{% url "admin:aircox_episode_change" episode.pk %}">{{ episode.title }}</a></td>
|
||||
<td>
|
||||
<a href="{% url "admin:aircox_episode_change" episode.pk %}">{{ episode.title }}</a>
|
||||
|
||||
{% if diffusion.type == diffusion.TYPE_ON_AIR %}
|
||||
<span class="tag is-info">
|
||||
<span class="icon is-small">
|
||||
{% if diffusion.is_live %}
|
||||
<i class="fa fa-microphone"
|
||||
title="{% trans "Live diffusion" %}"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-music"
|
||||
title="{% trans "Differed diffusion" %}"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
{{ diffusion.get_type_display }}
|
||||
</span>
|
||||
{% elif diffusion.type == diffusion.TYPE_CANCEL %}
|
||||
<span class="tag is-danger">
|
||||
{{ diffusion.get_type_display }}</span>
|
||||
{% elif diffusion.type == diffusion.TYPE_UNCONFIRMED %}
|
||||
<span class="tag is-warning">
|
||||
{{ diffusion.get_type_display }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
|
@ -56,6 +56,10 @@ Usefull context:
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
{% block top-nav-tools %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -1,5 +1,5 @@
|
||||
{% extends "aircox/basepage_detail.html" %}
|
||||
{% load static i18n humanize honeypot %}
|
||||
{% load static i18n humanize honeypot aircox %}
|
||||
{% comment %}
|
||||
Base template used to display a Page
|
||||
|
||||
@ -14,6 +14,19 @@ Context:
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block top-nav-tools %}
|
||||
{% has_perm page "change" as can_edit %}
|
||||
{% if can_edit %}
|
||||
<a class="navbar-item" href="{{ page|admin_url:'change' }}"
|
||||
target="new">
|
||||
<span class="icon is-small">
|
||||
<i class="fa fa-pen"></i>
|
||||
</span>
|
||||
<span>{% trans "Edit" %}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
{{ block.super }}
|
||||
|
||||
|
@ -2,6 +2,8 @@ import random
|
||||
import json
|
||||
|
||||
from django import template
|
||||
from django.contrib.admin.templatetags.admin_urls import admin_urlname
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from aircox.models import Page, Diffusion, Log
|
||||
@ -10,6 +12,12 @@ random.seed()
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(name='admin_url')
|
||||
def do_admin_url(obj, arg, pass_id=True):
|
||||
""" Reverse admin url for object """
|
||||
name = admin_urlname(obj._meta, arg)
|
||||
return reverse(name, args=(obj.id,)) if pass_id else reverse(name)
|
||||
|
||||
@register.filter(name='get_tracks')
|
||||
def do_get_tracks(obj):
|
||||
""" Get a list of track for the provided log, diffusion, or episode """
|
||||
@ -20,6 +28,14 @@ def do_get_tracks(obj):
|
||||
obj = obj.episode
|
||||
return obj.track_set.all()
|
||||
|
||||
@register.simple_tag(name='has_perm', takes_context=True)
|
||||
def do_has_perm(context, obj, perm, user=None):
|
||||
""" Return True if ``user.has_perm('[APP].[perm]_[MODEL]')`` """
|
||||
if user is None:
|
||||
user = context['request'].user
|
||||
return user.has_perm('{}.{}_{}'.format(
|
||||
obj._meta.app_label, perm, obj._meta.model_name))
|
||||
|
||||
@register.filter(name='is_diffusion')
|
||||
def do_is_diffusion(obj):
|
||||
""" Return True if object is a Diffusion. """
|
||||
|
Reference in New Issue
Block a user