You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
857 B

  1. # -*- coding: utf-8 -*-
  2. from odoo import http
  3. from odoo.exceptions import AccessError
  4. from odoo.http import request
  5. from ..environment_checkup.runtime import all_installed_checks, display_data
  6. from ..environment_checkup.core import CheckResult
  7. class Dashboard(http.Controller):
  8. @http.route('/galicea_environment_checkup/data', type='json', auth='user')
  9. def data(self, request, **kw):
  10. if not request.env.user.has_group('base.group_erp_manager'):
  11. raise AccessError("Access Denied")
  12. checks = all_installed_checks(request.env)
  13. response = display_data(request.env, checks)
  14. priority = {
  15. CheckResult.FAIL: 0,
  16. CheckResult.WARNING: 1,
  17. CheckResult.SUCCESS: 2
  18. }
  19. response.sort(key=lambda res: (priority[res['result']], res['module']))
  20. return response