| |
@@ -5,98 +5,79 @@
|
| |
import jinja2
|
| |
import requests
|
| |
|
| |
- chrome = panel("Pagure: Newest Open Tickets")
|
| |
+ chrome = panel("Newest Open Tickets on Pagure")
|
| |
|
| |
pagure_url = "https://pagure.io/api/0"
|
| |
|
| |
template = jinja2.Template("""
|
| |
- <br />
|
| |
- {% if message == "None" %}
|
| |
- <div class="container">
|
| |
- {% if total<3 %}
|
| |
- {% for i in range(0,total) %}
|
| |
- <div>
|
| |
- <table class="table-responsive table-condensed">
|
| |
- <tr>
|
| |
- <td valign="top" class="panel-heading">
|
| |
- <b>#{{ all_issues[i]['id'] }}</b>
|
| |
- </td>
|
| |
- <td width="260px">
|
| |
- <b>{{ all_issues[i]['title'] }}</b>
|
| |
- </td>
|
| |
- </tr>
|
| |
- </table>
|
| |
- <table class="table-responsive table-condensed">
|
| |
- <tr>
|
| |
- <td width="260px">
|
| |
- <font size="2">
|
| |
- <i>Opened by <a href="https://pagure.io/user/{{ all_issues[i]['user'] }}" target="_blank">{{ all_issues[i]['user'] }}</a></i>
|
| |
- {% if all_issues[i]['assignee']|string() == "None" %}
|
| |
- <br /><i>Unclaimed</i>
|
| |
- {% else %}
|
| |
- <br /><i>Assigned by <a href="https://pagure.io/user/{{ all_issues[i]['assignee'] }}" target="_blank">{{ all_issues[i]['assignee'] }}</a></i>
|
| |
- {% endif %}
|
| |
- </font>
|
| |
- </td>
|
| |
- <td>
|
| |
- <a href="https://pagure.io/{{ repo }}/issue/{{ all_issues[i]['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>
|
| |
+ <div class="container">
|
| |
+ <table id="pagure-issues-list"
|
| |
+ class="table table-hover table-striped m-b-0">
|
| |
+ <thead class="thead-default">
|
| |
+ <tr>
|
| |
+ <th id="project-title">Project</th>
|
| |
+ <th id="issue-title">Issue</th>
|
| |
+ <th class="open_by">Reporter</th>
|
| |
+ <th class="assigned">Assignee</th>
|
| |
+ </tr>
|
| |
+ </thead>
|
| |
+ <tfoot>
|
| |
+ </tfoot>
|
| |
+ <tbody>
|
| |
+ {% for issue in all_issues %}
|
| |
+ <tr>
|
| |
+ <td>
|
| |
+ {% if issue['issue_project_user'] %}
|
| |
+ <a href="https://pagure.io/forks/{{
|
| |
+ issue['issue_project_user'] }}/{{ issue['issue_project_name'] }}"
|
| |
+ target="_blank">
|
| |
+ {{ issue['issue_project_user'] }}/{{ issue['issue_project_name'] }}
|
| |
+ {% else %}
|
| |
+ <a href="https://pagure.io/{{
|
| |
+ issue['issue_project_name'] }}" target="_blank">
|
| |
+ {{ issue['issue_project_name'] }}
|
| |
+ {% endif %}
|
| |
+ </a>
|
| |
+ </td>
|
| |
+ <td>
|
| |
+ <span class="label label-default">#{{ issue['issue_id'] }}</span>
|
| |
+ <a href="https://pagure.io/{{ repo }}/pull-request/{{
|
| |
+ issue['issue_id'] }}" target="_blank"
|
| |
+ title="{{ issue['issue_title_full'] }}">>
|
| |
+ {{ issue['issue_title'] }} ...
|
| |
+ </a>
|
| |
+ </td>
|
| |
+ <td>
|
| |
+ <a href="https://pagure.io/user/{{ issue['issue_openedby'] }}"
|
| |
+ target="_blank">
|
| |
+ {{ issue['issue_openedby'] }}
|
| |
+ </a>
|
| |
+ </td>
|
| |
+ <td>
|
| |
+ {% if issue['issue_assignee'] %}
|
| |
+ <a href="https://pagure.io/user/{{issue['issue_assignee'] }}"
|
| |
+ target="_blank">
|
| |
+ {{issue['issue_assignee'] }}
|
| |
+ </a>
|
| |
+ {% else %}
|
| |
+ <span class="text-muted">unassigned</span>
|
| |
+ {% endif %}
|
| |
+ </td>
|
| |
+ </tr>
|
| |
{% endfor %}
|
| |
- {% else %}
|
| |
- {% for i in range(0,3) %}
|
| |
- <div>
|
| |
- <table class="table-responsive table-condensed">
|
| |
- <tr>
|
| |
- <td valign="top" class="panel-heading">
|
| |
- <b>#{{ all_issues[i]['id'] }}</b>
|
| |
- </td>
|
| |
- <td width="260px">
|
| |
- <b>{{ all_issues[i]['title'] }}</b>
|
| |
- </td>
|
| |
- </tr>
|
| |
- </table>
|
| |
- <table class="table-responsive table-condensed">
|
| |
- <tr>
|
| |
- <td width="260px">
|
| |
- <font size="2">
|
| |
- <i>Opened by <a href="https://pagure.io/user/{{ all_issues[i]['user'] }}" target="_blank">{{ all_issues[i]['user'] }}</a></i>
|
| |
- {% if all_issues[i]['assignee']|string() == "None" %}
|
| |
- <br /><i>Unclaimed</i>
|
| |
- {% else %}
|
| |
- <br /><i>Assigned to <a href="https://pagure.io/user/{{ all_issues[i]['assignee'] }}" target="_blank">{{ all_issues[i]['assignee'] }}</a></i>
|
| |
- {% endif %}
|
| |
- </font>
|
| |
- </td>
|
| |
- <td>
|
| |
- <a href="https://pagure.io/{{ repo }}/issue/{{ all_issues[i]['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 %}
|
| |
- {% endif %}
|
| |
- </div>
|
| |
- <div class="row">
|
| |
- <a href="https://pagure.io/{{ repo }}/issues" target="_blank"><center>All Issues</center></a>
|
| |
- </div>
|
| |
- {% else %}
|
| |
- <div class="container">
|
| |
- <b>Not a valid repo</b>
|
| |
+ </tbody>
|
| |
+ </table>
|
| |
+ </div class="row">
|
| |
+ <center>
|
| |
+ <a href="https://pagure.io/{{ repo }}/issues" target="_blank">
|
| |
+ All Issues
|
| |
+ </a>
|
| |
+ <center>
|
| |
</div>
|
| |
- {% endif %}
|
| |
+ </div>
|
| |
""")
|
| |
|
| |
+
|
| |
@argument(name="repo",
|
| |
default=None,
|
| |
validator=validators.repo,
|
| |
@@ -104,45 +85,48 @@
|
| |
def data(session, widget, repo):
|
| |
repo = "pagure"
|
| |
|
| |
- projects_response = requests.get("https://pagure.io/api/0/projects")
|
| |
- projects_data = projects_response.json()
|
| |
- total_projects = projects_data['total_projects']
|
| |
- all_projects = list()
|
| |
- for i in range(0, total_projects):
|
| |
- all_projects.append(projects_data['projects'][i]['name'])
|
| |
- if repo not in all_projects:
|
| |
- message = "Not a valid project"
|
| |
- return dict(
|
| |
- message=message,
|
| |
- )
|
| |
- else:
|
| |
- message = "None"
|
| |
- url = '/'.join([pagure_url, repo, "issues"])
|
| |
- issue_response = requests.get(url)
|
| |
- data = issue_response.json()
|
| |
- total = data['total_issues']
|
| |
- all_issues = list()
|
| |
- for i in range(0,total):
|
| |
- issue_details = dict()
|
| |
- issue_id=data['issues'][i]['id']
|
| |
- issue_title=data['issues'][i]['title']
|
| |
- issue_user=data['issues'][i]['user']['name']
|
| |
- if(data['issues'][i]['assignee']!=None):
|
| |
- issue_assignee=data['issues'][i]['assignee']['name']
|
| |
+ url = '/'.join([pagure_url, repo, "issues"])
|
| |
+ issue_response = requests.get(url)
|
| |
+ data = issue_response.json()
|
| |
+ total = data['total_issues']
|
| |
+
|
| |
+ all_issues = list()
|
| |
+ for issue in data['issues']:
|
| |
+
|
| |
+ issue_assignee = None
|
| |
+ if issue['assignee']:
|
| |
+ issue_assignee=issue['assignee']['name']
|
| |
+
|
| |
+ issue_project_user = None
|
| |
+ if 'project' in issue:
|
| |
+ issue_project_name = issue['project']['name']
|
| |
+ if issue['project']['parent']:
|
| |
+ issue_project_user = issue['project']['user']['username']
|
| |
else:
|
| |
- issue_assignee=data['issues'][i]['assignee']
|
| |
- issue_details['id']=issue_id
|
| |
- issue_details['title']=issue_title
|
| |
- issue_details['user']=issue_user
|
| |
- issue_details['assignee']=issue_assignee
|
| |
- all_issues.append(issue_details)
|
| |
- all_issues.reverse()
|
| |
- return dict(
|
| |
+ if '/' in repo:
|
| |
+ issue_project_name, issue_project_user = repo.split('/', 1)
|
| |
+ else:
|
| |
+ issue_project_name = repo
|
| |
+
|
| |
+ all_issues.append(
|
| |
+ dict(
|
| |
+ issue_project_name=issue_project_name,
|
| |
+ issue_project_user=issue_project_user,
|
| |
+ issue_id=issue['id'],
|
| |
+ issue_title=issue['title'][:45],
|
| |
+ issue_title_full=issue['title'],
|
| |
+ issue_openedby=issue['user']['name'],
|
| |
+ issue_assignee=issue_assignee,
|
| |
+ )
|
| |
+ )
|
| |
+
|
| |
+ all_issues.reverse()
|
| |
+
|
| |
+ return dict(
|
| |
repo=repo,
|
| |
total=total,
|
| |
all_issues=all_issues,
|
| |
- message = message,
|
| |
- )
|
| |
+ )
|
| |
|
| |
|
| |
@hint()
|
| |