Browse Source

Fixes #2133 (#2299)

pull/2303/head
Edward 6 years ago
committed by GitHub
parent
commit
3258080531
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      sapl/base/templatetags/common_tags.py
  2. 2
      sapl/templates/base.html
  3. 16
      sapl/templates/crud/detail.html

13
sapl/base/templatetags/common_tags.py

@ -198,6 +198,19 @@ def url(value):
return True return True
return False 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 @register.filter
def cronometro_to_seconds(value): def cronometro_to_seconds(value):

2
sapl/templates/base.html

@ -1,6 +1,6 @@
<!DOCTYPE html>
{% load i18n staticfiles sass_tags menus %} {% load i18n staticfiles sass_tags menus %}
{% load common_tags %} {% load common_tags %}
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <!--[if gt IE 8]><!-->
<html class="no-js" lang="pt-br"> <html class="no-js" lang="pt-br">

16
sapl/templates/crud/detail.html

@ -65,7 +65,21 @@
<div id="div_id_{{ column.id }}" class="form-group"> <div id="div_id_{{ column.id }}" class="form-group">
<p class="control-label">{{ column.verbose_name }}</p> <p class="control-label">{{ column.verbose_name }}</p>
<div class="controls"> <div class="controls">
{% if column.text|url %} {% if column.text|audio_url %}
<div class="form-control-static">
<audio controls>
<source src="{{ column.text|safe }}" type="audio/{{ column.text|file_extension }}">
<p>Este navegador não suporta o elemento áudio.</p>
</audio>
</div>
{% elif column.text|video_url %}
<div class="form-control-static">
<video width="320" height="120" controls>
<source src="{{ column.text|safe }}" type="video/{{ column.text|file_extension }}">
<p>Este navegador não suporta o elemento vídeo.</p>
</video>
</div>
{% elif column.text|url %}
<div class="form-control-static"><a href="{{ column.text|safe }}"> {{ column.text|safe|default:"" }} </a></div> <div class="form-control-static"><a href="{{ column.text|safe }}"> {{ column.text|safe|default:"" }} </a></div>
{% else %} {% else %}
<div class="form-control-static">{{ column.text|safe|default:"" }}</div> <div class="form-control-static">{{ column.text|safe|default:"" }}</div>

Loading…
Cancel
Save