Browse Source

v12_initial_fix

v12_initial_fix
Maciej Wawro 5 years ago
parent
commit
ae77d5f762
  1. 7
      galicea_environment_checkup/__init__.py
  2. 2
      galicea_environment_checkup/__manifest__.py
  3. 4
      galicea_environment_checkup/environment_checkup/__init__.py
  4. 2
      galicea_environment_checkup/environment_checkup/custom.py
  5. 2
      galicea_environment_checkup/environment_checkup/dependencies.py
  6. 2
      galicea_environment_checkup/environment_checkup/runtime.py
  7. 176
      galicea_environment_checkup/static/src/js/environment_checkup.js
  8. 108
      galicea_environment_checkup/static/src/js/environment_checkup10.js
  9. 2
      galicea_git/__manifest__.py
  10. 2
      galicea_openid_connect/__init__.py
  11. 8
      galicea_openid_connect/__manifest__.py
  12. 3
      galicea_openid_connect/api.py
  13. 1
      galicea_openid_connect/models/__init__.py
  14. 28
      galicea_openid_connect/models/config_parameter.py
  15. 8
      galicea_openid_connect/security/init.xml

7
galicea_environment_checkup/__init__.py

@ -1,7 +1,8 @@
# -*- coding: utf-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 controllers
from . import models
from environment_checkup.custom import custom_check
from environment_checkup.core import CheckFail, CheckWarning, CheckSuccess

2
galicea_environment_checkup/__manifest__.py

@ -11,7 +11,7 @@
'website': "http://galicea.pl", 'website': "http://galicea.pl",
'category': 'Technical Settings', 'category': 'Technical Settings',
'version': '10.0.1.0',
'version': '12.0.1.0',
'depends': ['web'], 'depends': ['web'],

4
galicea_environment_checkup/environment_checkup/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from . import core
from . import custom

2
galicea_environment_checkup/environment_checkup/custom.py

@ -2,7 +2,7 @@
import collections import collections
from core import Check
from .core import Check
custom_checks_per_module = collections.defaultdict(list) custom_checks_per_module = collections.defaultdict(list)

2
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.modules.module import load_information_from_description_file
from odoo.tools import which from odoo.tools import which
from core import Check, CheckSuccess, CheckWarning, CheckFail
from .core import Check, CheckSuccess, CheckWarning, CheckFail
class DependencyCheck(Check): class DependencyCheck(Check):
dependency_type = None dependency_type = None

2
galicea_environment_checkup/environment_checkup/runtime.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import custom, dependencies
from . import custom, dependencies
def all_installed_checks(env): def all_installed_checks(env):
result = [] result = []

176
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(){ start: function(){
return this.load(this.all_dashboards); return this.load(this.all_dashboards);
}, },
@ -73,16 +83,18 @@ odoo.define('galicea_environment_checkup', function(require) {
var loading_done = new $.Deferred(); var loading_done = new $.Deferred();
session.rpc('/galicea_environment_checkup/data', {}) session.rpc('/galicea_environment_checkup/data', {})
.then(function (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(); loading_done.resolve();
}); });
return loading_done; 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() { init: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.set("value", "[]"); this.set("value", "[]");
@ -99,10 +111,36 @@ odoo.define('galicea_environment_checkup', function(require) {
}); });
core.form_widget_registry.add('environment_checks', FormWidget); 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('<div />');
return;
}
this._replaceElement(QWeb.render('GaliceaEnvironmentCheckupFormWidget', {'data': data}));
}
});
////////////////////
return {
//!! SystrayIcon: SystrayIcon,
Dashboard: Dashboard, Dashboard: Dashboard,
FormWidget: FormWidget FormWidget: FormWidget
};
};
}); });

108
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('<div />');
return;
}
this.replaceElement(QWeb.render('GaliceaEnvironmentCheckupFormWidget', {'data': data}));
},
});
core.form_widget_registry.add('environment_checks', FormWidget);
return {
SystrayIcon: SystrayIcon,
Dashboard: Dashboard,
FormWidget: FormWidget
};
});

2
galicea_git/__manifest__.py

@ -9,7 +9,7 @@
'website': "http://galicea.pl", 'website': "http://galicea.pl",
'category': 'Technical Settings', 'category': 'Technical Settings',
'version': '10.0.1.0',
'version': '12.0.0.1',
'depends': ['web', 'galicea_environment_checkup'], 'depends': ['web', 'galicea_environment_checkup'],

2
galicea_openid_connect/__init__.py

@ -3,3 +3,5 @@
from . import controllers from . import controllers
from . import models from . import models
from . import system_checks from . import system_checks
#from . import api

8
galicea_openid_connect/__manifest__.py

@ -9,9 +9,9 @@
'website': "http://galicea.pl", 'website': "http://galicea.pl",
'category': 'Technical Settings', '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': { 'external_dependencies': {
'python': ['jwcrypto', 'cryptography'] 'python': ['jwcrypto', 'cryptography']
@ -20,8 +20,8 @@
'data': [ 'data': [
'security/security.xml', 'security/security.xml',
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'security/init.yml',
# 'security/init.yml',
'security/init.xml',
'views/views.xml', 'views/views.xml',
'views/templates.xml' 'views/templates.xml'
], ],

3
galicea_openid_connect/api.py

@ -79,8 +79,9 @@ def resource(path, method, auth='user'):
status=200 status=200
) )
except ApiException as e: except ApiException as e:
error_message = "error: {0}".format(e)
return werkzeug.Response( 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, status=400,
headers=cors_headers headers=cors_headers
) )

1
galicea_openid_connect/models/__init__.py

@ -2,3 +2,4 @@
from . import client from . import client
from . import access_token from . import access_token
from . import config_parameter

28
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)]
})

8
galicea_openid_connect/security/init.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<function model="ir.config_parameter"
name="openid_init_keys"
/>
</data>
</odoo>
Loading…
Cancel
Save