diff --git a/website_external_javascripts/__init__.py b/website_external_javascripts/__init__.py new file mode 100644 index 0000000..e7747f1 --- /dev/null +++ b/website_external_javascripts/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, an open source suite of business apps +# This module copyright (C) 2015 bloopark systems (). +# +# 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 . import models diff --git a/website_external_javascripts/__openerp__.py b/website_external_javascripts/__openerp__.py new file mode 100644 index 0000000..a955850 --- /dev/null +++ b/website_external_javascripts/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, an open source suite of business apps +# This module copyright (C) 2015 bloopark systems (). +# +# 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 . +# +############################################################################## +{ + 'name': 'Website External JavaScripts', + 'category': 'Website', + 'summary': 'Allow to embed external JavaScripts.', + 'version': '1.0', + 'author': "bloopark systems GmbH & Co. KG, " + "Odoo Community Association (OCA)", + 'website': "http://www.bloopark.de", + 'license': 'AGPL-3', + 'depends': [ + 'website' + ], + 'data': [ + 'views/website_extern_javascript_view.xml', + 'views/assets_website.xml', + 'security/ir.model.access.csv', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/website_external_javascripts/models/__init__.py b/website_external_javascripts/models/__init__.py new file mode 100644 index 0000000..ed5e08c --- /dev/null +++ b/website_external_javascripts/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, an open source suite of business apps +# This module copyright (C) 2015 bloopark systems (). +# +# 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 . import ir_ui_view +from . import website_extern_javascript diff --git a/website_external_javascripts/models/ir_ui_view.py b/website_external_javascripts/models/ir_ui_view.py new file mode 100644 index 0000000..115ab60 --- /dev/null +++ b/website_external_javascripts/models/ir_ui_view.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, an open source suite of business apps +# This module copyright (C) 2015 bloopark systems (). +# +# 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 import models + + +class IrUiView(models.Model): + + _inherit = 'ir.ui.view' + + def render(self, cr, uid, id_or_xml_id, values=None, engine='ir.qweb', + context=None): + if not values: + values = {} + + website_externjs = self.pool.get('website.extern.javascript') + + js_ids = website_externjs.search( + cr, uid, [('activated', '=', True)], context=context) + + values['javascripts'] = website_externjs.browse(cr, uid, js_ids, + context=context) + + return super(IrUiView, self).render(cr, uid, id_or_xml_id, values, + engine, context) diff --git a/website_external_javascripts/models/website_extern_javascript.py b/website_external_javascripts/models/website_extern_javascript.py new file mode 100644 index 0000000..d12ff4a --- /dev/null +++ b/website_external_javascripts/models/website_extern_javascript.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, an open source suite of business apps +# This module copyright (C) 2015 bloopark systems (). +# +# 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 import fields, models + + +class WebsiteExternJavaScript(models.Model): + + _name = 'website.extern.javascript' + + _order = 'sequence' + + activated = fields.Boolean('Activated') + + sequence = fields.Integer('Sequence', + help='Used for the order of the JavaScripts. ' + 'The higher the number the later the code ' + 'is embedded.') + + description = fields.Char('Description') + + type = fields.Selection([('url', 'URL'), ('code', 'Code')], 'Type') + + url = fields.Char('URL', help='URL of the JavaScript to embed.') + + code = fields.Text('Code', help='JavaScript to embed into the html code.') diff --git a/website_external_javascripts/security/ir.model.access.csv b/website_external_javascripts/security/ir.model.access.csv new file mode 100644 index 0000000..287f656 --- /dev/null +++ b/website_external_javascripts/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_javascript_public,website.extern.javascript,website_external_javascripts.model_website_extern_javascript,,1,0,0,0 +access_javascript,website.extern.javascript,website_external_javascripts.model_website_extern_javascript,base.group_website_designer,1,1,1,1 diff --git a/website_external_javascripts/views/assets_website.xml b/website_external_javascripts/views/assets_website.xml new file mode 100644 index 0000000..a47611b --- /dev/null +++ b/website_external_javascripts/views/assets_website.xml @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/website_external_javascripts/views/website_extern_javascript_view.xml b/website_external_javascripts/views/website_extern_javascript_view.xml new file mode 100644 index 0000000..ff2f879 --- /dev/null +++ b/website_external_javascripts/views/website_extern_javascript_view.xml @@ -0,0 +1,55 @@ + + + + + + website.extern.javascript.tree + website.extern.javascript + + + + + + + + + + + + website.extern.javascript.from + website.extern.javascript + primary + +
+ + + + + + + + + + + + + + +
+
+
+ + + Extern JavaScript + website.extern.javascript + form + tree,form + + + + +
+
\ No newline at end of file