From 48bd01e6f276f68a60b0d7104be2bca453ce169d Mon Sep 17 00:00:00 2001 From: Gery Debongnie Date: Mon, 14 Jul 2014 17:06:42 +0200 Subject: [PATCH] [IMP] add a res_config to the runbot it can save/get two keys: default_workers and default_running_max --- runbot/__init__.py | 1 + runbot/__openerp__.py | 1 + runbot/res_config.py | 53 ++++++++++++++++++++++++++++++++++++++ runbot/res_config_view.xml | 43 +++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 runbot/res_config.py create mode 100644 runbot/res_config_view.xml diff --git a/runbot/__init__.py b/runbot/__init__.py index ef0a414f..5b93fcf8 100644 --- a/runbot/__init__.py +++ b/runbot/__init__.py @@ -1 +1,2 @@ import runbot +import res_config diff --git a/runbot/__openerp__.py b/runbot/__openerp__.py index f4fbd0c0..c538112d 100644 --- a/runbot/__openerp__.py +++ b/runbot/__openerp__.py @@ -11,6 +11,7 @@ }, 'data': [ 'runbot.xml', + 'res_config_view.xml', 'security/ir.model.access.csv', ], 'installable': True, diff --git a/runbot/res_config.py b/runbot/res_config.py new file mode 100644 index 00000000..80e7b3ba --- /dev/null +++ b/runbot/res_config.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (C) 2004-2012 OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import fields, osv + +class runbot_config_settings(osv.osv_memory): + _name = 'runbot.config.settings' + _inherit = 'res.config.settings' + _columns = { + 'default_workers': fields.integer('Total Number of Workers'), + 'default_running_max': fields.integer('Maximum Number of Running Builds'), + } + + def get_default_parameters(self, cr, uid, fields, context=None): + icp = self.pool['ir.config_parameter'] + workers = icp.get_param(cr, uid, 'runbot.workers', default=6) + running_max = icp.get_param(cr, uid, 'runbot.running_max', default=75) + return { + 'default_workers': int(workers), + 'default_running_max': int(running_max) + } + + def set_default_parameters(self, cr, uid, ids, context=None): + config = self.browse(cr, uid, ids[0], context) + icp = self.pool['ir.config_parameter'] + icp.set_param(cr, uid, 'runbot.workers', config.default_workers) + icp.set_param(cr, uid, 'runbot.running_max', config.default_running_max) + + _defaults = { + 'default_workers': 6, + 'default_running_max': 75, + } + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/runbot/res_config_view.xml b/runbot/res_config_view.xml new file mode 100644 index 00000000..ba4c0a01 --- /dev/null +++ b/runbot/res_config_view.xml @@ -0,0 +1,43 @@ + + + + + + Configure Runbot + runbot.config.settings + +
+
+
+ + + + +
+
+ + Configure Runbot + ir.actions.act_window + runbot.config.settings + form + inline + + + +
+