From ed657ce69e3b3ce1b881a641b13477f7df0adc9f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 29 Nov 2018 14:24:22 +0100 Subject: [PATCH] Rework how we present flags on the PR list Signed-off-by: Pierre-Yves Chibon --- pagure/lib/model.py | 18 ++++++++ pagure/static/pagure.css | 3 +- pagure/templates/_render_pullrequests.html | 71 +++++++++++++++--------------- 3 files changed, 55 insertions(+), 37 deletions(-) diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 79b7ce63..1e6d9f43 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -2027,6 +2027,24 @@ class PullRequest(BASE): """ return [comment for comment in self.comments if not comment.commit_id] + @property + def flags_stats(self): + """ Return some stats about the flags associated with this PR. + """ + flags = self.flags + flags.reverse() + + # Only keep the last flag from each service + tmp = {} + for flag in flags: + tmp[flag.username] = flag + + output = collections.defaultdict(list) + for flag in tmp.values(): + output[flag.status].append(flag) + + return output + @property def score(self): """ Return the review score of the pull-request by checking the diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 2206f02a..dac79e7d 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -274,7 +274,8 @@ th[data-sort] { overflow:auto; } -.attachment_list p { +.attachment_list p, +.prs_flag_list p { margin-bottom: 0; } diff --git a/pagure/templates/_render_pullrequests.html b/pagure/templates/_render_pullrequests.html index 72db33f9..1aa79d91 100644 --- a/pagure/templates/_render_pullrequests.html +++ b/pagure/templates/_render_pullrequests.html @@ -46,17 +46,17 @@ {% endif %} {% endif %} - + {{request.branch}} - + {{request.user_comments|count}} - + {% if subtitle %} @@ -87,7 +87,7 @@ {% else %} - Opened + Opened {{ request.date_created | humanize}} by - {{ tag.tag }} - - {% endfor %} + {% for tag in request.tags %} + + {{ tag.tag }} + + {% endfor %} {% if request.flags %} -
- - {% for flag in request.flags | batch(1) | first %} - - - {{ flag.username }} - -
- - {{ flag.status }} - {%- if flag.percent %} ({{ flag.percent }}%) {%- endif %} -
- -
- {{ flag.comment }} -
- {{ flag.date_created | humanize }}
-
-
-
- {% endfor %} -
- {% else %} -

No builds for this request

+
+ {% set flags_stats = request.flags_stats %} + {% if flags_stats | length == 1 %} + {% for status in flags_stats %} +

{{ flags_stats[status][0].username }}: + + {{ flags_stats[status][0].status }} + +

+ {% endfor %} + {% else %} +

Flags: + {% for status in flags_stats %} + + {{ flags_stats[status] | length }} {{ status }} + +

+ {% endfor %} + {% endif %} +
{% endif %} -- 2.14.5