-
Couldn't load subscription status.
- Fork 79
fix #2622 #2646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #2622 #2646
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # ----------------------------------------------------------------------------- | ||
| # Copyright (c) 2014--, The Qiita Development Team. | ||
| # | ||
| # Distributed under the terms of the BSD 3-clause License. | ||
| # | ||
| # The full license is in the file LICENSE, distributed with this software. | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| from __future__ import division | ||
|
|
||
| from tornado.gen import coroutine | ||
| from tornado.web import HTTPError | ||
|
|
||
| from qiita_core.util import execute_as_transaction | ||
| from qiita_db.software import Software | ||
| from .base_handlers import BaseHandler | ||
|
|
||
|
|
||
| class SoftwareHandler(BaseHandler): | ||
| def check_access(self): | ||
| if self.current_user.level not in {'admin', 'dev'}: | ||
| raise HTTPError(405, reason="User %s doesn't have sufficient " | ||
| "privileges to view error page" % | ||
| self.current_user) | ||
|
||
|
|
||
| @coroutine | ||
| @execute_as_transaction | ||
| def get(self): | ||
| self.check_access() | ||
| software = Software.iter(False) | ||
| self.render("software.html", software=software) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| {% extends sitebase.html %} | ||
| {% block head %} | ||
| {% from future.utils import viewitems %} | ||
| {% from qiita_core.qiita_settings import qiita_config %} | ||
|
|
||
| <script type="text/javascript"> | ||
| $(document).ready(function() { | ||
| $('#error-table').dataTable({"order": [[1, "asc"]]}); | ||
| $("#waiting").hide(); | ||
| } ); | ||
| </script> | ||
|
|
||
| {% end %} | ||
|
|
||
| {% block content %} | ||
| {% if software %} | ||
| <table class="table-bordered" width="100%"> | ||
| <thead> | ||
| <tr> | ||
| <th>Software</th> | ||
| <th>Active</th> | ||
| <th>Commands</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for s in software %} | ||
| <tr> | ||
| <td>{{s.name}}, {{s.version}}</td> | ||
| <td> | ||
| {% if s.active %} | ||
| <span class="glyphicon glyphicon-thumbs-up" style="color:green"></span> | ||
| {% else %} | ||
| <span class="glyphicon glyphicon-thumbs-down" style="color:red"></span> | ||
| {% end %} | ||
| </td> | ||
| <td> | ||
| <table class="display table-bordered table-hover" width="100%"> | ||
| <thead> | ||
| <tr> | ||
| <th>Command</th> | ||
| <th>Active</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for c in s.commands %} | ||
| <tr> | ||
| <td>{{c.name}}</td> | ||
| <td> | ||
| {% if c.active %} | ||
| <span class="glyphicon glyphicon-thumbs-up" style="color:green"></span> | ||
| {% else %} | ||
| <span class="glyphicon glyphicon-thumbs-down" style="color:red"></span> | ||
| {% end %} | ||
| </td> | ||
| </tr> | ||
| {% end %} | ||
| </tbody> | ||
| </table> | ||
| </td> | ||
| </tr> | ||
| {% end %} | ||
| </tbody> | ||
| </table> | ||
| {% else %} | ||
| <div id="jumbotron" class="jumbotron"> | ||
| <h1><span class="glyphicon glyphicon-thumbs-down"></span> There is no plugin software in this system </h1> | ||
|
||
| </div> | ||
| {% end %} | ||
| {% end %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # ----------------------------------------------------------------------------- | ||
| # Copyright (c) 2014--, The Qiita Development Team. | ||
| # | ||
| # Distributed under the terms of the BSD 3-clause License. | ||
| # | ||
| # The full license is in the file LICENSE, distributed with this software. | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| from unittest import main | ||
| from qiita_pet.test.tornado_test_base import TestHandlerBase | ||
|
|
||
| from mock import Mock | ||
|
|
||
| from qiita_db.user import User | ||
| from qiita_pet.handlers.base_handlers import BaseHandler | ||
|
|
||
|
|
||
| class TestSoftware(TestHandlerBase): | ||
| def test_get(self): | ||
| response = self.get('/admin/software/') | ||
| self.assertEqual(response.code, 405) | ||
|
|
||
| BaseHandler.get_current_user = Mock(return_value=User("admin@foo.bar")) | ||
| response = self.get('/admin/software/') | ||
| self.assertEqual(response.code, 200) | ||
| self.assertNotEqual(response.body, "") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but this should be a 403 error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k, replacing everywhere ...