From 5d5a91de55a818649f1e3eb3cb70d0f0ae657b9f Mon Sep 17 00:00:00 2001 From: ulyssesBML Date: Thu, 27 Jun 2019 10:16:32 -0300 Subject: [PATCH] Resolvendo erros e melhorias relatados no pr --- sapl/base/templatetags/common_tags.py | 11 +++-------- sapl/templates/crud/detail.html | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 721c28e8a..0905bda94 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -223,14 +223,9 @@ def audio_url(value): @register.filter -def video_url(value): +def is_video_url(value): video_extensions = ["mp4", "ogg", "webm", "3gp", "ogv"] - has_ext = False - for i in video_extensions: - if value.endswith(i): - has_ext = True - break - + has_ext = any([value.endswith(i) for i in video_extensions]) return url(value) and has_ext @@ -249,7 +244,7 @@ def facebook_url(value): return True if r else False @register.filter -def get_youtube_id(value): +def youtube_id(value): from urllib.parse import urlparse, parse_qs u_pars = urlparse(value) quer_v = parse_qs(u_pars.query).get('v')[0] diff --git a/sapl/templates/crud/detail.html b/sapl/templates/crud/detail.html index 073606cad..2d4f86b91 100644 --- a/sapl/templates/crud/detail.html +++ b/sapl/templates/crud/detail.html @@ -72,7 +72,7 @@

Este navegador não suporta o elemento áudio.

- {% elif column.text|video_url %} + {% elif column.text|is_video_url %}
{% elif column.text|youtube_url %} {% elif column.text|facebook_url %}