From 6205ad80add9c222bde329489c3c86d1a0655a52 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Apr 08 2018 06:19:35 +0000 Subject: Improve human-readable date/time display in web UI There are many places in the web UI where we take a date/time (sourced either from a datetime or a timestamp) and turn it into some kind of human-readable form. There are mouseovers for the date/time a commit, PR or issue was created, the time it was last modified, and the date/time on each comment in an issue or PR, for instance. There were three problems with this. First, these weren't all consistent. Some used the format string '%b %d %Y %H:%M:%S', which gives something like "Mar 06 2018 23:44:27", while others used '%Y-%m-%d %H:%M:%S', which gives something like "2018-03-06 23:44:27". There's no reason these shouldn't be consistent, AFAICS. Second, neither of the existing forms indicates the timezone of the date/time, which is UTC. This isn't obvious for users: they may well assume the date/time given is in their local timezone. Ideally I'd actually like to *do* that, but doing it is hard; we can at least explicitly give the timezone in the string. Finally, we were constantly duplicating the format strings all over the templates, where it would make much more sense to just have a single filter function and use it every time we want to do this. This enforces consistency, and means that if we do want to change the format in future, we can change it in one place, not dozens of them. This was prompted by #3041 but doesn't entirely fix it. Signed-off-by: Adam Williamson --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index a1d98a1..9c2c6cc 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -113,7 +113,7 @@ {{ comment.date_created | humanize}} @@ -121,7 +121,7 @@
diff --git a/pagure/templates/forks.html b/pagure/templates/forks.html index 7e35b51..896f6db 100644 --- a/pagure/templates/forks.html +++ b/pagure/templates/forks.html @@ -30,7 +30,7 @@ forked this project + fork.date_created | format_datetime }}"> {{ fork.date_created|humanize }}
diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index e2ab290..951097e 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -33,14 +33,14 @@
Created {{ issue.date_created | humanize}} by {{ issue.user.user }}
{% if issue.last_updated %}
Modified {{ issue.last_updated | humanize}}
{% endif %} @@ -63,7 +63,7 @@
- {{ + {{ comment.date_created | humanize }}
{{ comment.comment | markdown | noJS | safe }} diff --git a/pagure/templates/issues.html b/pagure/templates/issues.html index d6150f3..c2e0cc7 100644 --- a/pagure/templates/issues.html +++ b/pagure/templates/issues.html @@ -263,19 +263,19 @@ {% endfor%} - {{ + {{ issue.date_created | humanize}} {% if status and status|lower != 'open' %} {% if issue.closed_at != None %} - {{ + {{ issue.closed_at | humanize}} {% endif %} {% else %} - {{ + {{ issue.last_updated | humanize}} {% endif %} diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index f155200..13b1d1d 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -85,14 +85,14 @@
Proposed {{ pull_request.date_created |humanize }} by {{ pull_request.user.default_email | avatar(16) | safe }} {{ pull_request.user.user }}
Modified {{ pull_request.last_updated |humanize }}
@@ -576,7 +576,7 @@ onclick="showTab()">{{ comment.line }} of {{ comment.filename }}.
- {{ + {{ comment.date_created | humanize }}
(Hide) @@ -590,7 +590,7 @@
- {{ + {{ comment.date_created | humanize }}
{{ comment.comment | markdown | noJS | safe }} diff --git a/pagure/templates/repo_stats.html b/pagure/templates/repo_stats.html index 17aa328..3971b8e 100644 --- a/pagure/templates/repo_stats.html +++ b/pagure/templates/repo_stats.html @@ -66,7 +66,7 @@ forked this project + fork.date_created | format_datetime }}"> {{ fork.date_created|humanize }}
diff --git a/pagure/templates/requests.html b/pagure/templates/requests.html index aaa399d..75d6a10 100644 --- a/pagure/templates/requests.html +++ b/pagure/templates/requests.html @@ -148,17 +148,17 @@ {{ request.branch }} - {{ + {{ request.date_created | humanize}} - {{ + {{ request.updated_on | humanize}} {% if status|lower not in ['open', 'true'] %} {{ request.closed_at | humanize diff --git a/pagure/templates/roadmap.html b/pagure/templates/roadmap.html index 2afb27e..d6ee572 100644 --- a/pagure/templates/roadmap.html +++ b/pagure/templates/roadmap.html @@ -68,18 +68,18 @@ {% endfor %} - {{ + {{ issue.date_created | humanize }} {% if status and status|lower == 'closed' %} {{ issue.closed_at | humanize }} {% else %} - {{ + {{ issue.last_updated | humanize }} {% endif %} diff --git a/pagure/templates/user_issues.html b/pagure/templates/user_issues.html index bc433f7..a8a29f0 100644 --- a/pagure/templates/user_issues.html +++ b/pagure/templates/user_issues.html @@ -66,11 +66,11 @@ - {{ + {{ issue.date_created | humanize}} - {{ + {{ issue.last_updated | humanize}} diff --git a/pagure/templates/user_list.html b/pagure/templates/user_list.html index cf3af3e..ffccea5 100644 --- a/pagure/templates/user_list.html +++ b/pagure/templates/user_list.html @@ -59,7 +59,7 @@
{{ user.user }} joined {{ + user.created | format_datetime }}">{{ user.created | humanize }}