From cecac7869bc791369457ed10a7c4ea7040b504cb Mon Sep 17 00:00:00 2001 From: jurek Date: Sun, 3 Nov 2019 06:39:00 +0100 Subject: [PATCH] 12.0 --- galicea_base/README.md | 1 + galicea_base/__init__.py | 2 + galicea_base/__manifest__.py | 23 +++ galicea_base/views/base_menu.xml | 6 + galicea_environment_checkup/__init__.py | 6 +- galicea_environment_checkup/__manifest__.py | 4 +- .../environment_checkup/__init__.py | 4 + .../environment_checkup/custom.py | 2 +- .../environment_checkup/dependencies.py | 10 +- .../environment_checkup/runtime.py | 2 +- .../static/src/js/environment_checkup.js | 176 +++++++++++------- .../static/src/js/environment_checkup10.js | 108 +++++++++++ .../static/src/xml/templates.xml | 6 +- galicea_environment_checkup/views/views.xml | 2 +- galicea_git/__manifest__.py | 4 +- galicea_git/controllers/main.py | 8 +- galicea_git/data/config.xml | 15 +- galicea_git/models/repository.py | 7 +- galicea_git/views/views.org.xml | 71 +++++++ galicea_git/views/views.xml | 37 +--- galicea_openapi/__init__.py | 5 + galicea_openapi/__manifest__.py | 33 ++++ galicea_openapi/controllers/__init__.py | 4 + galicea_openapi/controllers/api.py | 56 ++++++ galicea_openapi/doc/helloworld.py | 22 +++ galicea_openapi/doc/test1.py | 41 ++++ galicea_openapi/models/__init__.py | 3 + galicea_openapi/openapi.py | 52 ++++++ galicea_openapi/security/ir.model.access.csv | 2 + galicea_openapi/static/description/icon.png | Bin 0 -> 10404 bytes galicea_openid_connect/__init__.py | 2 + galicea_openid_connect/__manifest__.py | 8 +- galicea_openid_connect/api.py | 35 ++-- galicea_openid_connect/controllers/main.py | 13 +- galicea_openid_connect/models/__init__.py | 1 + galicea_openid_connect/models/client.py | 4 - .../models/config_parameter.py | 28 +++ galicea_openid_connect/random_tokens.py | 2 +- galicea_openid_connect/security/init.xml | 8 + galicea_openid_connect/views/views.xml | 5 +- galicea_toolset/README.md | 30 +++ galicea_toolset/__init__.py | 1 + galicea_toolset/__manifest__.py | 20 ++ .../src/js/.#one2many_flexible_widget.js | 1 + .../static/src/js/client_actions.js | 38 ++++ .../static/src/js/iframe_widget.js | 49 +++++ .../static/src/js/one2many_flexible_widget.js | 68 +++++++ galicea_toolset/utils.py | 16 ++ galicea_toolset/views/data.xml | 11 ++ 49 files changed, 882 insertions(+), 170 deletions(-) create mode 100644 galicea_base/README.md create mode 100644 galicea_base/__init__.py create mode 100644 galicea_base/__manifest__.py create mode 100644 galicea_base/views/base_menu.xml create mode 100644 galicea_environment_checkup/static/src/js/environment_checkup10.js create mode 100644 galicea_git/views/views.org.xml create mode 100644 galicea_openapi/__init__.py create mode 100644 galicea_openapi/__manifest__.py create mode 100644 galicea_openapi/controllers/__init__.py create mode 100644 galicea_openapi/controllers/api.py create mode 100644 galicea_openapi/doc/helloworld.py create mode 100644 galicea_openapi/doc/test1.py create mode 100644 galicea_openapi/models/__init__.py create mode 100644 galicea_openapi/openapi.py create mode 100644 galicea_openapi/security/ir.model.access.csv create mode 100644 galicea_openapi/static/description/icon.png create mode 100644 galicea_openid_connect/models/config_parameter.py create mode 100644 galicea_openid_connect/security/init.xml create mode 100644 galicea_toolset/README.md create mode 100644 galicea_toolset/__init__.py create mode 100644 galicea_toolset/__manifest__.py create mode 120000 galicea_toolset/static/src/js/.#one2many_flexible_widget.js create mode 100644 galicea_toolset/static/src/js/client_actions.js create mode 100644 galicea_toolset/static/src/js/iframe_widget.js create mode 100644 galicea_toolset/static/src/js/one2many_flexible_widget.js create mode 100644 galicea_toolset/utils.py create mode 100644 galicea_toolset/views/data.xml diff --git a/galicea_base/README.md b/galicea_base/README.md new file mode 100644 index 0000000..ffdcdb9 --- /dev/null +++ b/galicea_base/README.md @@ -0,0 +1 @@ +Base menu for Odoo Galicea Ecosystem diff --git a/galicea_base/__init__.py b/galicea_base/__init__.py new file mode 100644 index 0000000..633f866 --- /dev/null +++ b/galicea_base/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- + diff --git a/galicea_base/__manifest__.py b/galicea_base/__manifest__.py new file mode 100644 index 0000000..576af3e --- /dev/null +++ b/galicea_base/__manifest__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Base menu for Odoo Galicea Ecosystem", + + 'summary': """ + Menu only + """, + + 'author': "Jurek Wawro", + 'maintainer': "Galicea", + 'website': "http://galicea.pl", + + 'category': 'Technical Settings', + 'version': '12.0.1.0', + + 'depends': ['web',], + + 'data': [ + 'views/base_menu.xml', + ], + + 'installable': True +} diff --git a/galicea_base/views/base_menu.xml b/galicea_base/views/base_menu.xml new file mode 100644 index 0000000..02fc5b3 --- /dev/null +++ b/galicea_base/views/base_menu.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/galicea_environment_checkup/__init__.py b/galicea_environment_checkup/__init__.py index 3bb7ff0..03f3593 100644 --- a/galicea_environment_checkup/__init__.py +++ b/galicea_environment_checkup/__init__.py @@ -1,7 +1,9 @@ # -*- 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 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..164658b 100644 --- a/galicea_environment_checkup/__manifest__.py +++ b/galicea_environment_checkup/__manifest__.py @@ -11,9 +11,9 @@ 'website': "http://galicea.pl", 'category': 'Technical Settings', - 'version': '10.0.1.0', + 'version': '12.0.1.0', - 'depends': ['web'], + 'depends': ['web','galicea_base',], 'data': [ 'views/data.xml', 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..6dfdb94 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 @@ -36,8 +36,10 @@ class DependencyCheck(Check): version_operator = version[:2] version = version[2:] + # Py3 : map -> list(map + # https://stackoverflow.com/questions/33717314/attributeerror-map-obejct-has-no-attribute-index-python-3 try: - parsed_version = map(int, version.split('.')) + parsed_version = list(map(int, version.split('.'))) except ValueError: raise CheckFail( 'Invalid version expression', @@ -45,7 +47,7 @@ class DependencyCheck(Check): Allowed expressions are
=x.y.z
,
>=x.y.z
,
^x.z.y
,
~x.y.z. Got 
{}
""".format(cgi.escape(self.dependency['version'])) ) - parsed_installed_version = map(int, installed_version.split('.')) + parsed_installed_version = list(map(int, installed_version.split('.'))) parsed_version.extend(0 for _ in range(len(parsed_installed_version) - len(parsed_version))) parsed_installed_version.extend(0 for _ in range(len(parsed_version) - len(parsed_installed_version))) @@ -132,7 +134,7 @@ class ExternalDependencyCheck(DependencyCheck): def _installed_version(self, env, name): try: exe = which(name) - out = subprocess.check_output([exe, '--version']) + out = str(subprocess.check_output([exe, '--version'])) # Py3 str() match = re.search('[\d.]+', out) if not match: raise CheckWarning( 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 100644 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_environment_checkup/static/src/xml/templates.xml b/galicea_environment_checkup/static/src/xml/templates.xml index 12fa26e..7039c07 100644 --- a/galicea_environment_checkup/static/src/xml/templates.xml +++ b/galicea_environment_checkup/static/src/xml/templates.xml @@ -27,13 +27,13 @@
- + - + - +
diff --git a/galicea_environment_checkup/views/views.xml b/galicea_environment_checkup/views/views.xml index 7a4071b..c3c0b32 100644 --- a/galicea_environment_checkup/views/views.xml +++ b/galicea_environment_checkup/views/views.xml @@ -5,7 +5,7 @@ galicea_environment_checkup.dashboard + action="dashboard_action" parent="galicea_base.galicea_admin_menu" groups="base.group_erp_manager" /> module_form.checks diff --git a/galicea_git/__manifest__.py b/galicea_git/__manifest__.py index 63f5e8d..95e98f5 100644 --- a/galicea_git/__manifest__.py +++ b/galicea_git/__manifest__.py @@ -9,9 +9,9 @@ 'website': "http://galicea.pl", 'category': 'Technical Settings', - 'version': '10.0.1.0', + 'version': '12.0.0.1', - 'depends': ['web', 'galicea_environment_checkup'], + 'depends': ['web', 'galicea_environment_checkup','galicea_base'], 'external_dependencies': { 'bin': ['git'] diff --git a/galicea_git/controllers/main.py b/galicea_git/controllers/main.py index 96abad9..52f66c9 100644 --- a/galicea_git/controllers/main.py +++ b/galicea_git/controllers/main.py @@ -65,14 +65,14 @@ class Main(http.Controller): shell=True ) stdout, stderr = git.communicate(http_input_stream(request).read()) - headers_str, body = stdout.split("\r\n\r\n", 2) + headers_str, body = stdout.split(b"\r\n\r\n", 2) http_status_code = 200 headers = [] - for header in headers_str.split("\r\n"): - name, value = header.split(': ', 2) + for header in headers_str.split(b"\r\n"): + name, value = header.split(b': ', 2) if name == 'Status': - http_code = int(value.split(' ')[0]) + http_code = int(value.split(b' ')[0]) else: headers.append((name, value)) diff --git a/galicea_git/data/config.xml b/galicea_git/data/config.xml index 1c984af..7f998dc 100644 --- a/galicea_git/data/config.xml +++ b/galicea_git/data/config.xml @@ -1,9 +1,12 @@ + - - - galicea_git.git_http_backend - /usr/lib/git-core/git-http-backend - - + + + + galicea_git.git_http_backend + /usr/lib/git-core/git-http-backend + + + diff --git a/galicea_git/models/repository.py b/galicea_git/models/repository.py index 7a7561f..1607502 100644 --- a/galicea_git/models/repository.py +++ b/galicea_git/models/repository.py @@ -5,6 +5,11 @@ import random import shutil import string import subprocess +try: + import git +except ImportError: + pass + from odoo import models, fields, api, http from odoo.exceptions import ValidationError @@ -56,7 +61,7 @@ class Repository(models.Model): @api.constrains('system_name') def _validate_system_name(self): - allowed_characters = string.ascii_lowercase + string.digits + '-' + allowed_characters = string.ascii_lowercase + string.digits + '-_' if not all(c in allowed_characters for c in self.system_name): raise ValidationError( 'Only lowercase, digits and hyphens (-) are allowed in directory name' diff --git a/galicea_git/views/views.org.xml b/galicea_git/views/views.org.xml new file mode 100644 index 0000000..ea11d5f --- /dev/null +++ b/galicea_git/views/views.org.xml @@ -0,0 +1,71 @@ + + + + galicea_git.repository + +
+ + + + + + + + +
+
+
+ + + galicea_git.repository + + + + + + + + + + + + + galicea_git.config.settings + +
+
+
+ + +