diff --git a/panikdb/customtags/__init__.py b/panikdb/customtags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/panikdb/customtags/templatetags/__init__.py b/panikdb/customtags/templatetags/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/panikdb/customtags/templatetags/panikdbtags.py b/panikdb/customtags/templatetags/panikdbtags.py new file mode 100644 index 0000000000000000000000000000000000000000..3f478512263014d38ad79f24a777b45e1bdc8358 --- /dev/null +++ b/panikdb/customtags/templatetags/panikdbtags.py @@ -0,0 +1,16 @@ +from django.template import Library +from django.conf import settings + +from emissions.models import Emission, Episode, NewsItem + +register = Library() + +@register.filter +def online_url(object): + if isinstance(object, NewsItem): + return settings.WEBSITE_BASE_URL + 'news/' + object.slug + if isinstance(object, Emission): + return settings.WEBSITE_BASE_URL + 'emissions/' + object.slug + '/' + if isinstance(object, Episode): + return settings.WEBSITE_BASE_URL + 'emissions/' + object.emission.slug + '/' + object.slug + return 'XXX' diff --git a/panikdb/settings.py b/panikdb/settings.py index 36a3080bc1bd8f8d2af1c0147c02bef093e23d0f..008768d5b53e3b6375fc01605d6a25d2c6c71f02 100644 --- a/panikdb/settings.py +++ b/panikdb/settings.py @@ -132,6 +132,7 @@ INSTALLED_APPS = ( 'django_bootstrap_staticfiles', 'emissions', 'panikdb.aa', + 'panikdb.customtags', ) # A sample logging configuration. The only tangible logging @@ -189,6 +190,7 @@ CACHES = { AUTH_USER_MODEL = 'aa.User' LOGIN_REDIRECT_URL = '/' +WEBSITE_BASE_URL = 'http://test-web.radiopanik.org/' try: from local_settings import * diff --git a/panikdb/templates/base.html b/panikdb/templates/base.html index b485956736b23a6ac13d02c956451b5a52d1f23c..7bb56822aa8060166a65373f34a860015afcdc19 100644 --- a/panikdb/templates/base.html +++ b/panikdb/templates/base.html @@ -1,5 +1,6 @@ {% load url from future %} {% load i18n %} +{% load panikdbtags %} @@ -42,8 +43,10 @@ {% block user-links %} Accueil Statistiques - {% block online-page %} - + {% block online-url %} + {% if object %} + Voir en ligne + {% endif %} {% endblock %}