#364 Dropped FedoraHosted widget. Fixes #354.
Merged 4 years ago by abompard. Opened 4 years ago by sayaksarkar.
sayaksarkar/fedora-hubs drop/fhosted-widget  into  develop

file modified
-1
@@ -60,7 +60,6 @@ 

      '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',

@@ -57,11 +57,3 @@ 

              validators.PagureRepo.from_string("fedora-hubs"), "fedora-hubs")

          self.assertRaises(ValueError, validators.PagureRepo.from_string,

                            "something-that-does-not-exist")

- 

-     def test_fedorahosted_project(self):

-         self.assertEqual(

-             validators.FedorahostedProject.from_string("about-fedora"),

-             "about-fedora")

-         self.assertRaises(

-             ValueError, validators.FedorahostedProject.from_string,

-             "something-that-does-not-exist")

@@ -1,186 +0,0 @@ 

- interactions:

- - request:

-     body: null

-     headers:

-       Accept: ['*/*']

-       Accept-Encoding: ['gzip, deflate']

-       Connection: [keep-alive]

-       User-Agent: [python-requests/2.13.0]

-     method: GET

-     uri: https://fedorahosted.org/about-fedora/

-   response:

-     body: {string: "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"\

-         http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\"\

-         >\n  \n  \n\n  \n\n\n  <head>\n    <title>\n      about-fedora\n    </title>\n\

-         \    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"\

-         \ />\n    <!--[if IE]><script type=\"text/javascript\">\n      if (/^#__msie303:/.test(window.location.hash))\n\

-         \        window.location.replace(window.location.hash.replace(/^#__msie303:/,\

-         \ '#'));\n    </script><![endif]-->\n        <link rel=\"search\" href=\"\

-         /about-fedora/search\" />\n        <link rel=\"help\" href=\"/about-fedora/wiki/TracGuide\"\

-         \ />\n        <link rel=\"alternate\" href=\"/about-fedora/wiki/WikiStart?format=txt\"\

-         \ type=\"text/x-trac-wiki\" title=\"Plain Text\" />\n        <link rel=\"\

-         start\" href=\"/about-fedora/wiki\" />\n        <link rel=\"stylesheet\" href=\"\

-         /about-fedora/chrome/common/css/trac.css\" type=\"text/css\" /><link rel=\"\

-         stylesheet\" href=\"/about-fedora/chrome/common/css/wiki.css\" type=\"text/css\"\

-         \ /><link rel=\"stylesheet\" href=\"/about-fedora/chrome/tracvatar/tracvatar.css\"\

-         \ type=\"text/css\" />\n        <link rel=\"shortcut icon\" href=\"/about-fedora/chrome/common/trac.ico\"\

-         \ type=\"image/x-icon\" />\n        <link rel=\"icon\" href=\"/about-fedora/chrome/common/trac.ico\"\

-         \ type=\"image/x-icon\" />\n      <link type=\"application/opensearchdescription+xml\"\

-         \ rel=\"search\" href=\"/about-fedora/search/opensearch\" title=\"Search about-fedora\"\

-         \ />\n    <script type=\"text/javascript\" src=\"/about-fedora/chrome/common/js/jquery.js\"\

-         ></script><script type=\"text/javascript\" src=\"/about-fedora/chrome/common/js/babel.js\"\

-         ></script><script type=\"text/javascript\" src=\"/about-fedora/chrome/common/js/messages/en_US.js\"\

-         ></script><script type=\"text/javascript\" src=\"/about-fedora/chrome/common/js/trac.js\"\

-         ></script><script type=\"text/javascript\" src=\"/about-fedora/chrome/common/js/search.js\"\

-         ></script><script type=\"text/javascript\" src=\"/about-fedora/chrome/common/js/folding.js\"\

-         ></script>\n    <!--[if lt IE 7]>\n    <script type=\"text/javascript\" src=\"\

-         /about-fedora/chrome/common/js/ie_pre7_hacks.js\"></script>\n    <![endif]-->\n\

-         \    <script type=\"text/javascript\">\n      jQuery(document).ready(function($)\

-         \ {\n        $(\"#content\").find(\"h1,h2,h3,h4,h5,h6\").addAnchor(_(\"Link\

-         \ to this section\"));\n        $(\"#content\").find(\".wikianchor\").each(function()\

-         \ {\n          $(this).addAnchor(babel.format(_(\"Link to #%(id)s\"), {id:\

-         \ $(this).attr('id')}));\n        });\n        $(\".foldable\").enableFolding(true,\

-         \ true);\n      });\n    </script>\n  </head>\n  <body>\n    <div id=\"banner\"\

-         >\n      <div id=\"header\">\n        <a id=\"logo\" href=\"https://fedorahosted.org/\"\

-         ><img src=\"https://fedorahosted.org/web/static/images/fedora-hosted-banner.png\"\

-         \ alt=\"Fedora Hosted\" /></a>\n      </div>\n      <form id=\"search\" action=\"\

-         /about-fedora/search\" method=\"get\">\n        <div>\n          <label for=\"\

-         proj-search\">Search:</label>\n          <input type=\"text\" id=\"proj-search\"\

-         \ name=\"q\" size=\"18\" value=\"\" />\n          <input type=\"submit\" value=\"\

-         Search\" />\n        </div>\n      </form>\n      <div id=\"metanav\" class=\"\

-         nav\">\n    <ul>\n      <li class=\"first\"><a href=\"/about-fedora/openidlogin\"\

-         >OpenID Login</a></li><li><a href=\"https://admin.fedoraproject.org/accounts/user/new\"\

-         >Fedora Account Sign Up</a></li><li><a href=\"/about-fedora/prefs\">Preferences</a></li><li><a\

-         \ href=\"/about-fedora/wiki/TracGuide\">Help/Guide</a></li><li><a href=\"\

-         /about-fedora/about\">About Trac</a></li><li class=\"last\"><a href=\"http://git.fedorahosted.org/cgit/about-fedora.git\"\

-         >CGit</a></li>\n    </ul>\n  </div>\n    </div>\n    <div id=\"mainnav\" class=\"\

-         nav\">\n    <ul>\n      <li class=\"first active\"><a href=\"/about-fedora/wiki\"\

-         >Wiki</a></li><li><a href=\"/about-fedora/timeline\">Timeline</a></li><li><a\

-         \ href=\"/about-fedora/roadmap\">Roadmap</a></li><li><a href=\"/about-fedora/browser\"\

-         >Browse Source</a></li><li><a href=\"/about-fedora/report\">View Tickets</a></li><li\

-         \ class=\"last\"><a href=\"/about-fedora/search\">Search</a></li>\n    </ul>\n\

-         \  </div>\n    <div id=\"main\">\n      <div id=\"pagepath\" class=\"noprint\"\

-         >\n  <a class=\"pathentry first\" title=\"View WikiStart\" href=\"/about-fedora/wiki\"\

-         >wiki:</a><a class=\"pathentry\" href=\"/about-fedora/wiki/WikiStart\" title=\"\

-         View WikiStart\">WikiStart</a>\n</div>\n      <div id=\"ctxtnav\" class=\"\

-         nav\">\n        <h2>Context Navigation</h2>\n          <ul>\n            \

-         \  <li class=\"first\"><a href=\"/about-fedora/wiki/WikiStart\">Start Page</a></li><li><a\

-         \ href=\"/about-fedora/wiki/TitleIndex\">Index</a></li><li class=\"last\"\

-         ><a href=\"/about-fedora/wiki/WikiStart?action=history\">History</a></li>\n\

-         \          </ul>\n        <hr />\n      </div>\n    <div id=\"content\" class=\"\

-         wiki\">\n      <div class=\"wikipage searchable\">\n        \n          \n\

-         \          <div class=\"trac-modifiedby\">\n            <span><a href=\"/about-fedora/wiki/WikiStart?action=diff&amp;version=5\"\

-         \ title=\"Version 5 by quaid: adding step to self-intro\">Last modified</a>\

-         \ <a class=\"timeline\" href=\"/about-fedora/timeline?from=2009-02-09T03%3A57%3A48Z&amp;precision=second\"\

-         \ title=\"2009-02-09T03:57:48Z in Timeline\">8 years</a> ago</span>\n    \

-         \        <span class=\"trac-print\">Last modified on 02/09/09 03:57:48</span>\n\

-         \          </div>\n          <div id=\"wikipage\"><h1 id=\"Whatisthissite\"\

-         >What is this site?</h1>\n<p>\nThis is the source project for About Fedora.\

-         \  It includes a <tt>git</tt> repo and a database for tracking how we develop\

-         \ the source toolchain.  \n</p>\n<p>\nIt's all part of the <a class=\"ext-link\"\

-         \ href=\"https://fedoraproject.org/wiki/Overview\"><span class=\"icon\">\u200B\

-         </span>Fedora Project</a>.  This site, in particular, is run by the <a class=\"\

-         ext-link\" href=\"https://fedoraproject.org/wiki/DocsProject\"><span class=\"\

-         icon\">\u200B</span>Fedora Documentation team</a>.\n</p>\n<p>\nIf you want\

-         \ to look at what we've created, use the \"Browse Source\" link above and\

-         \ to the right.\n</p>\n<h1 id=\"AboutFedorahassomethingmissingorwrong.\">About\

-         \ Fedora has something missing or wrong.</h1>\n<p>\nIf you need to tell us\

-         \ that something is wrong in About Fedora, visit <a class=\"ext-link\" href=\"\

-         https://bugzilla.redhat.com/bugzilla\"><span class=\"icon\">\u200B</span>Bugzilla</a>.\

-         \  File a bug against the product \"Fedora Documentation,\" component \"about-fedora\"\

-         .\n</p>\n<h1 id=\"Iwanttohelpwiththecontent.\">I want to help with the content.</h1>\n\

-         <p>\nIf you want to help update the content of About Fedora, first <a class=\"\

-         ext-link\" href=\"http://fedoraproject.org/wiki/DocsProject/Join#Things_you_need_to_do\"\

-         ><span class=\"icon\">\u200B</span>introduce yourself to the Docs Project</a>.\

-         \  When you've done that, <a class=\"ext-link\" href=\"https://admin.fedoraproject.org/accounts/group/view/gitabout-fedora\"\

-         ><span class=\"icon\">\u200B</span>join our project group</a>.  Then visit\

-         \ <a class=\"ext-link\" href=\"https://fedoraproject.org/wiki/Docs_Project_work_using_git\"\

-         ><span class=\"icon\">\u200B</span>this page on the Fedora Project wiki</a>\

-         \ to find out how to get started using <tt>git</tt>.  These instructions should\

-         \ work for most people with access to this repository:\n</p>\n<pre class=\"\

-         wiki\">cd ~/projects/\ngit clone ssh://&lt;username&gt;@git.fedorahosted.org/git/docs/about-fedora.git\n\

-         git clone git://git.fedorahosted.org/git/fedora-doc-utils docs-common\n</pre><p>\n\

-         If you don't have access to this repo, use <tt>git://</tt> instead of <tt>ssh://</tt>\

-         \ above.\n</p>\n<h1 id=\"Iwanttotranslatethecontenttomylanguage.\">I want\

-         \ to translate the content to my language.</h1>\n<p>\nCheck the <a class=\"\

-         ext-link\" href=\"http://translate.fedoraproject.org/module/docs-about-fedora\"\

-         ><span class=\"icon\">\u200B</span>statistics page</a> to get details about\

-         \ your language and join the <a class=\"ext-link\" href=\"https://fedoraproject.org/wiki/L10N\"\

-         ><span class=\"icon\">\u200B</span>Fedora Translation team</a> if your language\

-         \ is not available.\n</p>\n<h1 id=\"Imconfused.Whatisthissitefor\">I'm confused.\

-         \ What is this site for?</h1>\n<p>\nIf you have questions, come visit the\

-         \ Docs Project on IRC.  IRC is a way to communicate in real time with other\

-         \ Fedora Project members.  You can find more information <a class=\"ext-link\"\

-         \ href=\"https://fedoraproject.org/wiki/Communicate/IRC\"><span class=\"icon\"\

-         >\u200B</span>here</a>.\n</p>\n</div>\n        \n        \n      </div>\n\

-         \      \n\n    </div>\n    <div id=\"altlinks\">\n      <h3>Download in other\

-         \ formats:</h3>\n      <ul>\n        <li class=\"last first\">\n         \

-         \ <a rel=\"nofollow\" href=\"/about-fedora/wiki/WikiStart?format=txt\">Plain\

-         \ Text</a>\n        </li>\n      </ul>\n    </div>\n    </div>\n    <div id=\"\

-         footer\" lang=\"en\" xml:lang=\"en\"><hr />\n      <a id=\"tracpowered\" href=\"\

-         http://trac.edgewall.org/\"><img src=\"/about-fedora/chrome/common/trac_logo_mini.png\"\

-         \ height=\"30\" width=\"107\" alt=\"Trac Powered\" /></a>\n      <p class=\"\

-         left\">Powered by <a href=\"/about-fedora/about\"><strong>Trac 0.12.5</strong></a><br\

-         \ />\n        By <a href=\"http://www.edgewall.org/\">Edgewall Software</a>.<p\

-         \ class=\"left\">Libravatar support by <a href=\"https://bitbucket.org/zzzeek/tracvatar\"\

-         >Tracvatar 1.9</a></p></p>\n      <p class=\"right\">Visit the Trac open source\

-         \ project at<br /><a href=\"http://trac.edgewall.org/\">http://trac.edgewall.org/</a></p>\n\

-         \    </div>\n    <!-- Tack on our fedmenu stuff for this trac. -->\n    <script\

-         \ src=\"https://apps.fedoraproject.org/fedmenu/js/jquery-1.11.2.min.js\"></script>\n\

-         \    <script src=\"https://apps.fedoraproject.org/fedmenu/js/fedmenu.js\"\

-         ></script>\n    <script>\n      fedmenu({\n        'url': 'https://apps.fedoraproject.org/js/data.js',\n\

-         \        'mimeType': 'application/javascript',\n        'position': 'bottom-right',\n\

-         \      });\n    </script>\n  </body>\n</html>"}

-     headers:

-       cache-control: [must-revalidate]

-       connection: [Keep-Alive]

-       content-length: ['9437']

-       content-type: [text/html;charset=utf-8]

-       date: ['Tue, 14 Feb 2017 10:57:38 GMT']

-       expires: ['Fri, 01 Jan 1999 00:00:00 GMT']

-       keep-alive: ['timeout=5, max=500']

-       server: [Apache/2.2.15 (Red Hat)]

-       set-cookie: [trac_form_token=8344c426dbc2cc320d5e431d; Path=/about-fedora, 'trac_session=808a3fc5547b36ddaca5f057;

-           expires=Mon, 15-May-2017 10:57:39 GMT; Path=/about-fedora']

-       strict-transport-security: [max-age=15768000; includeSubDomains; preload]

-     status: {code: 200, message: Ok}

- - request:

-     body: null

-     headers:

-       Accept: ['*/*']

-       Accept-Encoding: ['gzip, deflate']

-       Connection: [keep-alive]

-       User-Agent: [python-requests/2.13.0]

-     method: GET

-     uri: https://fedorahosted.org/something-that-does-not-exist/

-   response:

-     body: {string: !!python/unicode '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

- 

-         <html><head>

- 

-         <title>302 Found</title>

- 

-         </head><body>

- 

-         <h1>Found</h1>

- 

-         <p>The document has moved <a href="https://fedorahosted.org/web/410">here</a>.</p>

- 

-         <hr>

- 

-         <address>Apache/2.2.15 (Red Hat) Server at fedorahosted.org Port 443</address>

- 

-         </body></html>

- 

-         '}

-     headers:

-       connection: [Keep-Alive]

-       content-length: ['300']

-       content-type: [text/html; charset=iso-8859-1]

-       date: ['Tue, 14 Feb 2017 10:57:40 GMT']

-       keep-alive: ['timeout=5, max=500']

-       location: ['https://fedorahosted.org/web/410']

-       server: [Apache/2.2.15 (Red Hat)]

-       strict-transport-security: [max-age=15768000; includeSubDomains; preload]

-     status: {code: 302, message: Found}

- version: 1

@@ -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

@@ -1,48 +0,0 @@ 

- {% extends "templates/panel.html" %}

- 

- {% block content %}

- {% if error %}

- <p>{{ error }}</p>

- {% else %}

- <a class="btn btn-success" target="_blank"

-     href="https://fedorahosted.org/{{ project }}/report/1">

-   All Issues

- </a>

- <hr/>

- 

- <ul class="media-list">

-   {% for issue in tickets %}

-     <li class="media">

-       <div class="media-left">

-         <a  href="https://fedorahosted.org/{{ project }}/ticket/{{ issue['id'] }}"

-             target="_blank">

-         <span class="label label-default">#{{ issue['id'] }}</span>

-         </a>

-       </div>

-       <div class="media-body">

-         <h4 class="media-heading">

-           <span title="{{ issue['summary'] }}">

-             {{ issue['short_summary'] }} {% if

-               issue['summary'] | length > 45 %} ... {% endif %}

-           </span>

-         </h4>

-         Opened by:

-             {{ issue['reporter'] }}

-         --

-         {% if issue['owner'] %}

-           Assigned to:

-             {{issue['owner'] }}

-         {% else %}

-           <span class="text-muted">Unassigned</span>

-         {% endif %}

-       </div>

-     </li>

-   {% endfor %}

-   {% if total_tickets > tickets | length %}

-   <li>

-     And {{ total_tickets - tickets | length }} more ...

-   </li>

-   {% endif %}

- </ul>

- {% endif %}

- {% endblock %}

@@ -138,18 +138,6 @@ 

          raise ValueError('Invalid pagure repo')

  

  

- class FedorahostedProject(Validator):

-     """Fails if the FedoraHosted project name does not exist."""

- 

-     @classmethod

-     def from_string(cls, value):

-         response = requests.get("https://fedorahosted.org/%s/" % value,

-                                 timeout=5, allow_redirects=False)

-         if response.status_code == 200:

-             return value

-         raise ValueError('Invalid fedorahosted project')

- 

- 

  class CommaSeparatedList(Validator):

      """Fails if the value isn't a comma-separated list.

  

First PR for fedora-hubs. Please comment if something is incorrect and needs correction. Fixes #354.

rebased

4 years ago

rebased

4 years ago

rebased

4 years ago

There's one more thing: the fhosted widget is using the validators.FedorahostedProject validator. It should be removed too, along with the unit tests for this validator (and the VCR files that go with that unit test).

To help you, you can run this command: git grep -i fedorahosted, it will show you all instances of fedorahosted in the source code.

1 new commit added

  • Removed the FedoraHostedProject validator along with its unit tests and VCR files.
4 years ago

Pull-Request has been merged by abompard

4 years ago