From 803d728271fa46411e1536a3d872e37d0a28ccd4 Mon Sep 17 00:00:00 2001 From: Michael Watters Date: Dec 04 2018 08:18:11 +0000 Subject: Add build status to pull requests page This change causes pagure to show the status of the most recent flags from each third party application. Merges #4073 --- diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 79b7ce6..1e6d9f4 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -2028,6 +2028,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 number of +1, -1, :thumbup: and :thumbdown: in the comment of the diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 2206f02..dac79e7 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 f886ce2..1aa79d9 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 %} +
+ {% 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 %} + + {% endif %}