From 8782ae2ce9ad032227a0ddb931c6bbd7fd6946cc Mon Sep 17 00:00:00 2001 From: Julen Landa Alustiza Date: Aug 20 2020 13:02:26 +0000 Subject: ui/filters: new filter for humanized dates with tooltip --- diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 98b2741..a0eba49 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -80,6 +80,21 @@ def format_ts(string): return arr.strftime("%Y-%m-%d %H:%M:%S %Z") +@UI_NS.app_template_filter("humanize_tooltip") +def humanize_with_tooltip(date): + """ Template filter returning a human readable time string with an + UTC timestamp tooltip + """ + if date: + humanized = humanize_date(date) + utc = format_ts(date) + output = '{humanized}'.format( + utc=utc, humanized=humanized + ) + return output + return "" + + @UI_NS.app_template_filter("linkify") def linkify_text(text): """ escape all html tags with bleach, then use bleach to linkify