From 7f1424e6fa96098dd063fc53eee2c85331cda047 Mon Sep 17 00:00:00 2001 From: Sayak Sarkar Date: Jul 26 2017 13:53:48 +0000 Subject: Dropped FedoraHosted widget. Fixes #354. --- diff --git a/hubs/default_config.py b/hubs/default_config.py index ab47804..3924a1f 100644 --- a/hubs/default_config.py +++ b/hubs/default_config.py @@ -60,7 +60,6 @@ WIDGETS = [ 'hubs.widgets.linechart:Linechart', 'hubs.widgets.fedmsgstats:FedmsgStats', 'hubs.widgets.feed:Feed', - 'hubs.widgets.fhosted:FedoraHosted', 'hubs.widgets.github_pr:GitHubPRs', 'hubs.widgets.githubissues:GitHubIssues', 'hubs.widgets.halp:Halp', diff --git a/hubs/widgets/fhosted/__init__.py b/hubs/widgets/fhosted/__init__.py deleted file mode 100644 index b17eb7a..0000000 --- a/hubs/widgets/fhosted/__init__.py +++ /dev/null @@ -1,89 +0,0 @@ -from __future__ import unicode_literals - -from six.moves.xmlrpc_client import ServerProxy - -from hubs.widgets import validators -from hubs.widgets.base import Widget -from hubs.widgets.view import RootWidgetView -from hubs.widgets.caching import CachedFunction - - -class FedoraHosted(Widget): - - name = "fhosted" - label = "Fedorahosted: Open Tickets" - position = "right" - parameters = [ - dict( - name="project", - label="Project", - default=None, - validator=validators.FedorahostedProject, - help="Name of the trac instance on fedorahosted.org.", - ), dict( - name="n_tickets", - label="Number of tickets", - default=4, - validator=validators.Integer, - help="The number of tickets to display.", - )] - - -class BaseView(RootWidgetView): - - def get_context(self, instance, *args, **kwargs): - get_tickets = GetTickets(instance) - context = dict( - title=self.widget.label, - project=instance.config["project"], - ) - context.update(get_tickets()) - return context - - -class GetTickets(CachedFunction): - ''' Data for Fedorahosted widget. - Queries Fedorahosted via xmlrpc for tickets. ''' - - def execute(self): - n_tickets = self.instance.config["n_tickets"] - url = 'https://fedorahosted.org/%s/rpc' \ - % self.instance.config["project"] - filters = 'status=accepted&status=assigned&status=new&status=reopened'\ - '&col=id&col=summary&col=status&col=owner&col=type&col=priority'\ - '&col=milestone&col=changetime&order=changetime' - - # get the tickets based on the filters - # returns a list of ticket ids - try: - server = ServerProxy(url) - tickets = server.ticket.query(filters) - except: - return dict( - error='Invalid or wrongly configured project' - ) - - output = [] - total_tickets = len(tickets) - for ticket in tickets[:n_tickets]: - # get the details of the ticket - ticket = server.ticket.get(ticket) - data = ticket[3] - data['id'] = ticket[0] - data['short_summary'] = data['summary'][:45] - output.append(data) - - return dict( - tickets=output, - total_tickets=total_tickets, - ) - - def should_invalidate(self, message): - ''' Checks if the Fedorahosted widget needs an update. - Called by backend daemon listening to fedmsg ''' - if '.trac.ticket' in message['topic']: - project = self.instance.config.get("project", "") - url = 'https://fedorahosted.org/%s/' % project - if message['msg']['instance']['base_url'] == url: - return True - return False diff --git a/hubs/widgets/fhosted/templates/root.html b/hubs/widgets/fhosted/templates/root.html deleted file mode 100644 index 5dcc574..0000000 --- a/hubs/widgets/fhosted/templates/root.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "templates/panel.html" %} - -{% block content %} -{% if error %} -

{{ error }}

-{% else %} - - All Issues - -
- - -{% endif %} -{% endblock %}