From 8782ae2ce9ad032227a0ddb931c6bbd7fd6946cc Mon Sep 17 00:00:00 2001 From: Julen Landa Alustiza Date: Aug 20 2020 13:02:26 +0000 Subject: [PATCH 1/2] 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 From 4850a7ba7de8d05d11d62db1c6defb0968f516a2 Mon Sep 17 00:00:00 2001 From: Julen Landa Alustiza Date: Aug 20 2020 13:02:26 +0000 Subject: [PATCH 2/2] pagure/templates: replace humanize with humanize_tooltip where has sense --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index 047cf34..714211d 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -207,7 +207,7 @@
- Attached {{ attachment[3] | humanize}} + Attached {{ attachment[3] | humanize_tooltip | safe}} {% if attachment[4] is not none %} View Comment {% else %} diff --git a/pagure/templates/_render_issues.html b/pagure/templates/_render_issues.html index dea0d16..2cbacbc 100644 --- a/pagure/templates/_render_issues.html +++ b/pagure/templates/_render_issues.html @@ -68,9 +68,7 @@ issue.date_created | format_datetime }}">{{ issue.date_created | humanize}} by {{ issue.user.user }}. - Modified {{ issue.last_updated | humanize}} + Modified {{ issue.last_updated | humanize_tooltip | safe }} {% if showproject %} diff --git a/pagure/templates/_render_pullrequests.html b/pagure/templates/_render_pullrequests.html index 4f3d325..a8b56e7 100644 --- a/pagure/templates/_render_pullrequests.html +++ b/pagure/templates/_render_pullrequests.html @@ -64,38 +64,26 @@ {% if request.status|lower == 'merged'%} Merged - {{ request.closed_at | humanize}}. + {{ request.closed_at | humanize_tooltip | safe }}. - Opened {{ request.date_created | humanize}} by {{ request.user.user }}. {% elif request.status|lower == 'closed' %} Cancelled - {{ request.closed_at | humanize}}. - Opened {{ request.date_created | humanize}} by {{ request.user.user }}. {% else %} Opened - {{ request.date_created | humanize}} by {{ request.user.user }}. - Modified {{ request.updated_on | humanize}} - + Modified {{ request.updated_on | humanize_tooltip | safe }} + {% endif %} {% if showproject %} diff --git a/pagure/templates/_render_repo.html b/pagure/templates/_render_repo.html index cfd0bb8..3ed23eb 100644 --- a/pagure/templates/_render_repo.html +++ b/pagure/templates/_render_repo.html @@ -56,7 +56,7 @@
- created {{repo.date_created|humanize}} + created {{repo.date_created|humanize_tooltip | safe}}
diff --git a/pagure/templates/commit.html b/pagure/templates/commit.html index 484bf49..73408ec 100644 --- a/pagure/templates/commit.html +++ b/pagure/templates/commit.html @@ -37,9 +37,7 @@ {% else %} Merged and Committed by {{ commit.author | author2user |safe }} {% endif %} - - {{ commit.commit_time | humanize }} - + {{ commit.commit_time | humanize_tooltip | safe }} {% else %} {{ diff|count}} file{{'s' if diff|count > 1 }} {% if commit.parents | length == 1 %} @@ -47,13 +45,9 @@ {% else %} Merged by {{ commit.author | author2user |safe }} {% endif %} - - {{ commit.commit_time | humanize }} - , + {{ commit.commit_time | humanize_tooltip | safe }}, Committed by {{ commit.committer | author2user |safe }} - - {{ commit.commit_time | humanize }} - , + {{ commit.commit_time | humanize_tooltip | safe }}, {% endif%}
@@ -245,7 +239,7 @@ flag.date_created == flag.date_updated -%} Created at {% else -%} Updated at {% endif -%} {{ flag.date_updated }}" class="pull-xs-right"> - {{ flag.date_updated | humanize }}
+ {{ flag.date_updated | humanize_tooltip | safe }}
diff --git a/pagure/templates/group_info.html b/pagure/templates/group_info.html index 36a2f71..1e6088f 100644 --- a/pagure/templates/group_info.html +++ b/pagure/templates/group_info.html @@ -21,7 +21,7 @@

{{group.display_name }}

{% if group.description %}
{{ group.description }}
{% endif %}
- formed {{ group.created |humanize }}, + formed {{ group.created |humanize_tooltip | safe }}, administered by {{ group.creator.user }}
diff --git a/pagure/templates/group_list.html b/pagure/templates/group_list.html index 0bed5bc..4bcb643 100644 --- a/pagure/templates/group_list.html +++ b/pagure/templates/group_list.html @@ -45,7 +45,7 @@
- Formed {{ group.created |humanize }} + Formed {{ group.created |humanize_tooltip | safe }}
diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 2a2a5fa..2e5c51d 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -168,8 +168,7 @@ namespace=repo.namespace, repo=repo.name, issueid=issueid)
{{ comment.comment | markdown | noJS | safe }}
- {{ - comment.date_created | humanize }} + {{ comment.date_created | humanize_tooltip | safe }}
{% else %} @@ -638,7 +637,7 @@ namespace=repo.namespace, repo=repo.name, issueid=issueid) namespace=pr.project.namespace, requestid=pr.id) }}">#{{pr.id}} {{ pr.status if pr.status != 'Open' else 'Last updated' - }} {{ pr.updated_on | humanize }} + }} {{ pr.updated_on | humanize_tooltip | safe }} {% endfor %} diff --git a/pagure/templates/releases.html b/pagure/templates/releases.html index 3fc1a12..1ca3182 100644 --- a/pagure/templates/releases.html +++ b/pagure/templates/releases.html @@ -66,10 +66,10 @@ {{tag['tagname']}} -
{{ tag['head_msg'] }} • {{tag['date'] | humanize}}
+
{{ tag['head_msg'] }} • {{tag['date'] | humanize_tooltip | safe}}
{% else %}
{{tag['tagname']}}
-
{{tag['date'] | humanize}}
+
{{tag['date'] | humanize_tooltip | safe}}
{% endif %}
diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index 15609c6..a5f74d3 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -64,15 +64,15 @@ namespace=repo.parent.namespace)}}"> {{ repo.parent.fullname }} - {{repo.date_created|humanize}} + {{repo.date_created|humanize_tooltip | safe}} {% elif repo.is_fork and not repo.parent %} - Forked from a deleted repository {{repo.date_created|humanize}} + Forked from a deleted repository {{repo.date_created|humanize_tooltip | safe}} {% endif %} {% if not repo.is_fork %} -
Created {{repo.date_created|humanize}}
+
Created {{repo.date_created|humanize_tooltip | safe}}
Maintained by @@ -284,7 +284,7 @@
- {{ commit.author | author2avatar(20) | safe }} {{commit.author.name}} committed {{ commit.commit_time|humanize }} + {{ commit.author | author2avatar(20) | safe }} {{commit.author.name}} committed {{ commit.commit_time|humanize_tooltip | safe }}
{% endif %} diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html index 75ed514..9d96f92 100644 --- a/pagure/templates/repo_master.html +++ b/pagure/templates/repo_master.html @@ -74,11 +74,11 @@ namespace=repo.parent.namespace)}}"> {{ repo.parent.fullname }} - {{repo.date_created|humanize}} + {{repo.date_created|humanize_tooltip | safe}} {% elif repo.is_fork and not repo.parent %} - Forked from a deleted repository {{repo.date_created|humanize}} + Forked from a deleted repository {{repo.date_created|humanize_tooltip | safe}} {% endif %} diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index 2581c5c..5eec6b8 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -396,8 +396,7 @@ {{ comment.comment | markdown | noJS | safe }}
- {{ - comment.date_created | humanize }} + {{ comment.date_created | humanize_tooltip | safe }}
{% else %} diff --git a/pagure/templates/user_list.html b/pagure/templates/user_list.html index 1c1b02e..277243a 100644 --- a/pagure/templates/user_list.html +++ b/pagure/templates/user_list.html @@ -42,9 +42,7 @@
- joined {{ - user.created | humanize }} + joined {{ user.created | humanize_tooltip | safe }}
diff --git a/pagure/templates/userdash_activity.html b/pagure/templates/userdash_activity.html index 043accf..bed781f 100644 --- a/pagure/templates/userdash_activity.html +++ b/pagure/templates/userdash_activity.html @@ -77,7 +77,7 @@ {{render_reponame(log.project)}}
- {{log.date_created|humanize}} + {{log.date_created|humanize_tooltip | safe}}
@@ -99,7 +99,7 @@ {{render_reponame(log.project)}}
- {{log.date_created|humanize}} + {{log.date_created|humanize_tooltip | safe}}
@@ -113,7 +113,7 @@ {{render_reponame(log.project)}}
- {{log.date_created|humanize}} + {{log.date_created|humanize_tooltip | safe}}
{% elif self.log_type == 'committed' %} diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index a0eba49..55a2ca0 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -88,9 +88,8 @@ def humanize_with_tooltip(date): if date: humanized = humanize_date(date) utc = format_ts(date) - output = '{humanized}'.format( - utc=utc, humanized=humanized - ) + output = '{humanized}' + output = output.format(utc=utc, humanized=humanized) return output return "" diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index 8e8dce1..8efa8eb 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -4360,7 +4360,8 @@ More information # Checking if Edited by User is there or not pattern = ( re.escape("Edited ") - + "(just now|seconds ago)" + + '(just now|seconds ago)' + re.escape(" by pingou ") ) self.assertIsNotNone(re.search(pattern, output_text))