| |
@@ -0,0 +1,80 @@
|
| |
+ from hubs.hinting import hint
|
| |
+ from hubs.widgets.chrome import panel
|
| |
+ import jinja2
|
| |
+ import requests
|
| |
+ from hubs.widgets.base import argument
|
| |
+ import hubs.validators as validators
|
| |
+ chrome = panel("Pagure: Newest Open Pull Requests")
|
| |
+
|
| |
+ pagure_url = "https://pagure.io/api/0"
|
| |
+
|
| |
+ template = jinja2.Template("""
|
| |
+ <br />
|
| |
+ <div class="container">
|
| |
+ {% for i in range(0,total_req) %}
|
| |
+ <div>
|
| |
+ <table class="table-responsive table-condensed">
|
| |
+ <tr>
|
| |
+ <td valign="top" class="panel-heading">
|
| |
+ <b>#{{ all_pr[i]['pr_id'] }}</b>
|
| |
+ </td>
|
| |
+ <td width="260px">
|
| |
+ <b>{{ all_pr[i]['pr_title'] }} ...</b>
|
| |
+ </td>
|
| |
+ </tr>
|
| |
+ </table>
|
| |
+ <table class="table-responsive table-condensed">
|
| |
+ <tr>
|
| |
+ <td width="280px" >
|
| |
+ <font size="2">
|
| |
+ <i>Opened by <a href="https://pagure.io/user/{{ all_pr[i]['pr_openedby'] }}" target="_blank">{{ all_pr[i]['pr_openedby'] }}</a>
|
| |
+ {% if all_pr[i]['pr_assignee'] %}
|
| |
+ <br>Assigned to <a href="https://pagure.io/user/{{ all_pr[i]['pr_assignee'] }}" target="_blank">{{ all_pr[i]['pr_assignee'] }}</a></i>
|
| |
+ {% endif %}
|
| |
+ </font>
|
| |
+ </td>
|
| |
+ <td>
|
| |
+ <a href="https://pagure.io/{{ repo }}/pull-request/{{ all_pr[i]['pr_id'] }}" target="_blank">
|
| |
+ <button type="button" class="btn btn-default" aria-label="Left Align">
|
| |
+ <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
| |
+ </button>
|
| |
+ </a>
|
| |
+ </td>
|
| |
+ </tr>
|
| |
+ </table>
|
| |
+ </div>
|
| |
+ {%endfor%}
|
| |
+ <br />
|
| |
+ </div class="row">
|
| |
+ <center><a href="https://pagure.io/{{ repo }}/pull-requests" target="_blank">All Pull-Requests</a><center>
|
| |
+ </div>
|
| |
+ </div>
|
| |
+ """)
|
| |
+
|
| |
+ @argument(name="repo",
|
| |
+ default=None,
|
| |
+ validator=validators.repo,
|
| |
+ help="Repo")
|
| |
+ def data(session, widget, repo):
|
| |
+ repo="pagure"
|
| |
+ url = '/'.join([pagure_url, repo, "pull-requests"])
|
| |
+ response = requests.get(url)
|
| |
+ data = response.json()
|
| |
+ total_req = data['total_requests']
|
| |
+ all_pr = list()
|
| |
+ for i in range(0,total_req):
|
| |
+ all_pr.append(dict(
|
| |
+ pr_id=data['requests'][i]['id'],
|
| |
+ pr_title=data['requests'][i]['title'][:45],
|
| |
+ pr_openedby=data['requests'][i]['user']['name'],
|
| |
+ pr_assignee=data['requests'][i]['assignee'],
|
| |
+ ))
|
| |
+ all_pr.reverse()
|
| |
+ return dict(all_pr=all_pr,
|
| |
+ total_req=total_req,
|
| |
+ repo=repo,
|
| |
+ )
|
| |
+
|
| |
+ @hint()
|
| |
+ def should_invalidate(message, session, widget):
|
| |
+ raise NotImplementedError
|
| |