diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 71f63e130..440f747a4 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -198,6 +198,19 @@ def url(value): return True return False +@register.filter +def audio_url(value): + return True if url(value) and value.endswith("mp3") else False + + +@register.filter +def video_url(value): + return True if url(value) and value.endswith("mp4") else False + +@register.filter +def file_extension(value): + import pathlib + return pathlib.Path(value).suffix.replace('.', '') @register.filter def cronometro_to_seconds(value): diff --git a/sapl/templates/base.html b/sapl/templates/base.html index c7cfd8b69..b93260845 100644 --- a/sapl/templates/base.html +++ b/sapl/templates/base.html @@ -1,6 +1,6 @@ + {% load i18n staticfiles sass_tags menus %} {% load common_tags %} - diff --git a/sapl/templates/crud/detail.html b/sapl/templates/crud/detail.html index 4a1cad276..c1b2c6445 100644 --- a/sapl/templates/crud/detail.html +++ b/sapl/templates/crud/detail.html @@ -65,7 +65,21 @@

{{ column.verbose_name }}

- {% if column.text|url %} + {% if column.text|audio_url %} +
+ +
+ {% elif column.text|video_url %} +
+ +
+ {% elif column.text|url %} {% else %}
{{ column.text|safe|default:"" }}