diff --git a/galicea_environment_checkup/__init__.py b/galicea_environment_checkup/__init__.py index 3bb7ff0..91046f6 100644 --- a/galicea_environment_checkup/__init__.py +++ b/galicea_environment_checkup/__init__.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -from . import models +from .environment_checkup.custom import custom_check +from .environment_checkup.core import CheckFail, CheckWarning, CheckSuccess + from . import controllers +from . import models -from environment_checkup.custom import custom_check -from environment_checkup.core import CheckFail, CheckWarning, CheckSuccess diff --git a/galicea_environment_checkup/__manifest__.py b/galicea_environment_checkup/__manifest__.py index 2d82ce7..42184a1 100644 --- a/galicea_environment_checkup/__manifest__.py +++ b/galicea_environment_checkup/__manifest__.py @@ -11,7 +11,7 @@ 'website': "http://galicea.pl", 'category': 'Technical Settings', - 'version': '10.0.1.0', + 'version': '12.0.1.0', 'depends': ['web'], diff --git a/galicea_environment_checkup/environment_checkup/__init__.py b/galicea_environment_checkup/environment_checkup/__init__.py index e69de29..6368420 100644 --- a/galicea_environment_checkup/environment_checkup/__init__.py +++ b/galicea_environment_checkup/environment_checkup/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import core +from . import custom diff --git a/galicea_environment_checkup/environment_checkup/custom.py b/galicea_environment_checkup/environment_checkup/custom.py index ec0b8f9..a9943f4 100644 --- a/galicea_environment_checkup/environment_checkup/custom.py +++ b/galicea_environment_checkup/environment_checkup/custom.py @@ -2,7 +2,7 @@ import collections -from core import Check +from .core import Check custom_checks_per_module = collections.defaultdict(list) diff --git a/galicea_environment_checkup/environment_checkup/dependencies.py b/galicea_environment_checkup/environment_checkup/dependencies.py index 13aeeeb..012522a 100644 --- a/galicea_environment_checkup/environment_checkup/dependencies.py +++ b/galicea_environment_checkup/environment_checkup/dependencies.py @@ -6,7 +6,7 @@ import cgi from odoo.modules.module import load_information_from_description_file from odoo.tools import which -from core import Check, CheckSuccess, CheckWarning, CheckFail +from .core import Check, CheckSuccess, CheckWarning, CheckFail class DependencyCheck(Check): dependency_type = None diff --git a/galicea_environment_checkup/environment_checkup/runtime.py b/galicea_environment_checkup/environment_checkup/runtime.py index b9bc9b7..252f8cc 100644 --- a/galicea_environment_checkup/environment_checkup/runtime.py +++ b/galicea_environment_checkup/environment_checkup/runtime.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import custom, dependencies +from . import custom, dependencies def all_installed_checks(env): result = [] diff --git a/galicea_environment_checkup/static/src/js/environment_checkup.js b/galicea_environment_checkup/static/src/js/environment_checkup.js index c6fec5a..6445bd0 100644 --- a/galicea_environment_checkup/static/src/js/environment_checkup.js +++ b/galicea_environment_checkup/static/src/js/environment_checkup.js @@ -1,69 +1,79 @@ -odoo.define('galicea_environment_checkup', function(require) { - "use strict"; - - var core = require('web.core'); - var form_common = require('web.form_common'); - var Widget = require('web.Widget'); - var session = require('web.session'); - var QWeb = core.qweb; - var SystrayMenu = require('web.SystrayMenu'); - var Model = require('web.Model'); - - var Users = new Model('res.users'); - - var SystrayIcon = Widget.extend({ - tagName: 'li', - events: { - "click": "on_click", - }, - - start: function(){ - this.load(this.all_dashboards); - return this._super(); - }, - - load: function(dashboards){ - var self = this; - var loading_done = new $.Deferred(); - Users.call('has_group', ['base.group_erp_manager']).then(function(is_admin) { - if (is_admin) { - session.rpc('/galicea_environment_checkup/data', {}) - .then(function (data) { - var counts = { 'success': 0, 'warning': 0, 'fail': 0 }; - data.forEach(function (check) { ++counts[check.result]; }); - - var result; - if (counts['fail']) { - result = 'fail'; - } else if (counts['warning']) { - result = 'warning'; - } else { - result = 'success'; - } - - self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupIcon', { - 'result': result, - 'count': counts['warning'] + counts['fail'] - })); - loading_done.resolve(); - }); - } else { - loading_done.resolve(); - } - }); +odoo.define('galicea_environment_checkup', function (require) { +"use strict"; + +//var SystrayMenu = require('web.SystrayMenu'); +//var Model = require('web.Model'); + +var AbstractAction = require('web.AbstractAction'); +var core = require('web.core'); +//var framework = require('web.framework'); +var session = require('web.session'); +//var Widget = require('web.Widget'); +////////////////// +var QWeb = core.qweb; +//var _t = core._t; + +/* SystrayIcon - nie dziaƂa poprawnie ??? +//https://www.odoo.com/documentation/12.0/reference/javascript_reference.html +var Model = require('web.Model'); + +var Users = new Model('res.users'); + +var SystrayIcon = Widget.extend({ + tagName: 'li', + events: { + "click": "on_click", + }, + + start: function(){ + this.load(this.all_dashboards); + return this._super(); + }, + + load: function(dashboards){ + var self = this; + var loading_done = new $.Deferred(); + Users.call('has_group', ['base.group_erp_manager']).then(function(is_admin) { + if (is_admin) { + session.rpc('/galicea_environment_checkup/data', {}) + .then(function (data) { + var counts = { 'success': 0, 'warning': 0, 'fail': 0 }; + data.forEach(function (check) { ++counts[check.result]; }); + + var result; + if (counts['fail']) { + result = 'fail'; + } else if (counts['warning']) { + result = 'warning'; + } else { + result = 'success'; + } + + self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupIcon', { + 'result': result, + 'count': counts['warning'] + counts['fail'] + })); + loading_done.resolve(); + }); + } else { + loading_done.resolve(); + } + }); - return loading_done; - }, + return loading_done; + }, - on_click: function (event) { - event.preventDefault(); - this.do_action('galicea_environment_checkup.dashboard_action', {clear_breadcrumbs: true}); - }, - }); + on_click: function (event) { + event.preventDefault(); + this.do_action('galicea_environment_checkup.dashboard_action', {clear_breadcrumbs: true}); + }, +}); - SystrayMenu.Items.push(SystrayIcon); +*/ - var Dashboard = Widget.extend({ +///////////////////////////// +var Dashboard = AbstractAction.extend({ +// v.10 var Dashboard = Widget.extend({ start: function(){ return this.load(this.all_dashboards); }, @@ -73,16 +83,18 @@ odoo.define('galicea_environment_checkup', function(require) { var loading_done = new $.Deferred(); session.rpc('/galicea_environment_checkup/data', {}) .then(function (data) { - self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupDashboard', {'data': data})); + self._replaceElement(QWeb.render('GaliceaEnvironmentCheckupDashboard', {'data': data})); // v.10: self.replaceElement loading_done.resolve(); }); return loading_done; }, }); - core.action_registry.add('galicea_environment_checkup.dashboard', Dashboard); - - var FormWidget = form_common.AbstractField.extend({ +//!JW - nowa propozycja: core.action_registry.add('galicea_environment_checkup.environment_checkup', Dashboard); +core.action_registry.add('galicea_environment_checkup.dashboard', Dashboard); +//////////////////// +/* v.10 +var FormWidget = form_common.AbstractField.extend({ init: function() { this._super.apply(this, arguments); this.set("value", "[]"); @@ -99,10 +111,36 @@ odoo.define('galicea_environment_checkup', function(require) { }); core.form_widget_registry.add('environment_checks', FormWidget); +*/ +var FormView = require('web.FormView'); + +var FormWidget = FormView.extend({ + + template: "environment_checks", - return { - SystrayIcon: SystrayIcon, + init: function() { + this._super.apply(this, arguments); + this.set("value", "[]"); + }, + + events: { + }, + + render_value: function() { + var data = JSON.parse(this.get('value')); + if (data.length == 0) { + this._replaceElement('
'); + return; + } + this._replaceElement(QWeb.render('GaliceaEnvironmentCheckupFormWidget', {'data': data})); + } +}); + +//////////////////// +return { +//!! SystrayIcon: SystrayIcon, Dashboard: Dashboard, FormWidget: FormWidget - }; +}; + }); diff --git a/galicea_environment_checkup/static/src/js/environment_checkup10.js b/galicea_environment_checkup/static/src/js/environment_checkup10.js new file mode 100755 index 0000000..c6fec5a --- /dev/null +++ b/galicea_environment_checkup/static/src/js/environment_checkup10.js @@ -0,0 +1,108 @@ +odoo.define('galicea_environment_checkup', function(require) { + "use strict"; + + var core = require('web.core'); + var form_common = require('web.form_common'); + var Widget = require('web.Widget'); + var session = require('web.session'); + var QWeb = core.qweb; + var SystrayMenu = require('web.SystrayMenu'); + var Model = require('web.Model'); + + var Users = new Model('res.users'); + + var SystrayIcon = Widget.extend({ + tagName: 'li', + events: { + "click": "on_click", + }, + + start: function(){ + this.load(this.all_dashboards); + return this._super(); + }, + + load: function(dashboards){ + var self = this; + var loading_done = new $.Deferred(); + Users.call('has_group', ['base.group_erp_manager']).then(function(is_admin) { + if (is_admin) { + session.rpc('/galicea_environment_checkup/data', {}) + .then(function (data) { + var counts = { 'success': 0, 'warning': 0, 'fail': 0 }; + data.forEach(function (check) { ++counts[check.result]; }); + + var result; + if (counts['fail']) { + result = 'fail'; + } else if (counts['warning']) { + result = 'warning'; + } else { + result = 'success'; + } + + self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupIcon', { + 'result': result, + 'count': counts['warning'] + counts['fail'] + })); + loading_done.resolve(); + }); + } else { + loading_done.resolve(); + } + }); + + return loading_done; + }, + + on_click: function (event) { + event.preventDefault(); + this.do_action('galicea_environment_checkup.dashboard_action', {clear_breadcrumbs: true}); + }, + }); + + SystrayMenu.Items.push(SystrayIcon); + + var Dashboard = Widget.extend({ + start: function(){ + return this.load(this.all_dashboards); + }, + + load: function(dashboards) { + var self = this; + var loading_done = new $.Deferred(); + session.rpc('/galicea_environment_checkup/data', {}) + .then(function (data) { + self.replaceElement(QWeb.render('GaliceaEnvironmentCheckupDashboard', {'data': data})); + loading_done.resolve(); + }); + return loading_done; + }, + }); + + core.action_registry.add('galicea_environment_checkup.dashboard', Dashboard); + + var FormWidget = form_common.AbstractField.extend({ + init: function() { + this._super.apply(this, arguments); + this.set("value", "[]"); + }, + + render_value: function() { + var data = JSON.parse(this.get('value')); + if (data.length == 0) { + this.replaceElement('
'); + return; + } + this.replaceElement(QWeb.render('GaliceaEnvironmentCheckupFormWidget', {'data': data})); + }, + }); + + core.form_widget_registry.add('environment_checks', FormWidget); + + return { + SystrayIcon: SystrayIcon, + Dashboard: Dashboard, + FormWidget: FormWidget + }; +}); diff --git a/galicea_git/__manifest__.py b/galicea_git/__manifest__.py index 63f5e8d..33782cc 100644 --- a/galicea_git/__manifest__.py +++ b/galicea_git/__manifest__.py @@ -9,7 +9,7 @@ 'website': "http://galicea.pl", 'category': 'Technical Settings', - 'version': '10.0.1.0', + 'version': '12.0.0.1', 'depends': ['web', 'galicea_environment_checkup'], diff --git a/galicea_openid_connect/__init__.py b/galicea_openid_connect/__init__.py index 26e263a..44707aa 100644 --- a/galicea_openid_connect/__init__.py +++ b/galicea_openid_connect/__init__.py @@ -3,3 +3,5 @@ from . import controllers from . import models from . import system_checks + +#from . import api diff --git a/galicea_openid_connect/__manifest__.py b/galicea_openid_connect/__manifest__.py index bc24662..92a5016 100644 --- a/galicea_openid_connect/__manifest__.py +++ b/galicea_openid_connect/__manifest__.py @@ -9,9 +9,9 @@ 'website': "http://galicea.pl", 'category': 'Technical Settings', - 'version': '10.0.1.1', + 'version': '12.0.0.0', - 'depends': ['web', 'galicea_environment_checkup'], + 'depends': ['web', 'galicea_environment_checkup' ], 'external_dependencies': { 'python': ['jwcrypto', 'cryptography'] @@ -20,8 +20,8 @@ 'data': [ 'security/security.xml', 'security/ir.model.access.csv', - 'security/init.yml', - +# 'security/init.yml', + 'security/init.xml', 'views/views.xml', 'views/templates.xml' ], diff --git a/galicea_openid_connect/api.py b/galicea_openid_connect/api.py index bf19be2..8b33e40 100644 --- a/galicea_openid_connect/api.py +++ b/galicea_openid_connect/api.py @@ -79,8 +79,9 @@ def resource(path, method, auth='user'): status=200 ) except ApiException as e: + error_message = "error: {0}".format(e) return werkzeug.Response( - response=json.dumps({'error': e.code, 'error_message': e.message}), + response=json.dumps({'error': e.code, 'error_message': error_message}), status=400, headers=cors_headers ) diff --git a/galicea_openid_connect/models/__init__.py b/galicea_openid_connect/models/__init__.py index c5f0513..d6be90d 100644 --- a/galicea_openid_connect/models/__init__.py +++ b/galicea_openid_connect/models/__init__.py @@ -2,3 +2,4 @@ from . import client from . import access_token +from . import config_parameter \ No newline at end of file diff --git a/galicea_openid_connect/models/config_parameter.py b/galicea_openid_connect/models/config_parameter.py new file mode 100755 index 0000000..ffa9286 --- /dev/null +++ b/galicea_openid_connect/models/config_parameter.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api +from .. import random_tokens +try: + from jwcrypto import jwk +except ImportError: + pass + +class ConfigParameter(models.Model): + _inherit = 'ir.config_parameter' + + @api.model + def openid_init_keys(self): + keys = { + 'galicea_openid_connect.authorization_code_jwk': lambda: \ + jwk.JWK.generate(kty='oct', size=256, kid=random_tokens.alpha_numeric(16), use='sig', alg='HS256').export(), + 'galicea_openid_connect.id_token_jwk': lambda: \ + jwk.JWK.generate(kty='RSA', size=2054, kid=random_tokens.alpha_numeric(16), use='sig', alg='RS256').export() + } + + for key, gen in iter(keys.items()): + if not self.search([('key', '=', key)]): + self.create({ + 'key': key, + 'value': gen(), + 'group_ids': [(4, self.env.ref('base.group_erp_manager').id)] + }) diff --git a/galicea_openid_connect/security/init.xml b/galicea_openid_connect/security/init.xml new file mode 100755 index 0000000..6a8285d --- /dev/null +++ b/galicea_openid_connect/security/init.xml @@ -0,0 +1,8 @@ + + + + + +