Commit 75e4571e authored by fred's avatar fred

add a contextual button to top links

parent c219eaaa
from django.template import Library from django.template import Library
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse
from emissions.models import Emission, Episode, NewsItem from emissions.models import Emission, Episode, NewsItem
...@@ -14,3 +15,21 @@ def online_url(object): ...@@ -14,3 +15,21 @@ def online_url(object):
if isinstance(object, Episode): if isinstance(object, Episode):
return settings.WEBSITE_BASE_URL + 'emissions/' + object.emission.slug + '/' + object.slug return settings.WEBSITE_BASE_URL + 'emissions/' + object.emission.slug + '/' + object.slug
return 'XXX' return 'XXX'
@register.filter
def context_url(object):
if isinstance(object, NewsItem) and object.emission:
return reverse('emission-view', kwargs={'slug': object.emission.slug})
if isinstance(object, Episode):
return reverse('emission-view', kwargs={'slug': object.emission.slug})
return None
@register.filter
def context_title(object):
if isinstance(object, NewsItem) and object.emission:
return object.emission.title
if isinstance(object, Episode):
return object.emission.title
return None
...@@ -471,9 +471,13 @@ span.add-on { ...@@ -471,9 +471,13 @@ span.add-on {
background: #aaa; background: #aaa;
} }
#user-links span.middle {
padding-left: 15px;
}
#user-links span.right { #user-links span.right {
position: absolute; position: absolute;
right: 15px; right: 20px;
} }
......
...@@ -49,6 +49,16 @@ ...@@ -49,6 +49,16 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% if object %}
{% with object|context_url as context_url %}
{% if context_url %}
<span class="middle">
<a href="{{ object|context_url }} ">{{ object|context_title }}</a>
</span>
{% endif %}
{% endwith %}
{% endif %}
<span class="right"> <span class="right">
<a href="{% url 'auth_password_change' %}">Changement de mot de passe</a> <a href="{% url 'auth_password_change' %}">Changement de mot de passe</a>
<a href="{% url 'logout' %}">Déconnexion</a> <a href="{% url 'logout' %}">Déconnexion</a>
......
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