From 9a858f7daa6ee86a51eace446bec38327b7f9960 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Fri, 18 Apr 2014 14:50:43 +0200 Subject: [PATCH] [ADD] website_certification: new module to display certificated people on website bzr revid: rim@openerp.com-20140418125043-mhe8u8f18pov0nce --- addons/website_certification/__init__.py | 23 ++++++++ addons/website_certification/__openerp__.py | 38 ++++++++++++ addons/website_certification/certification.py | 43 ++++++++++++++ .../controllers/__init__.py | 22 +++++++ .../website_certification/controllers/main.py | 50 ++++++++++++++++ .../security/ir.model.access.csv | 7 +++ .../views/website_certification_templates.xml | 42 ++++++++++++++ .../views/website_certification_views.xml | 58 +++++++++++++++++++ 8 files changed, 283 insertions(+) create mode 100644 addons/website_certification/__init__.py create mode 100644 addons/website_certification/__openerp__.py create mode 100644 addons/website_certification/certification.py create mode 100644 addons/website_certification/controllers/__init__.py create mode 100644 addons/website_certification/controllers/main.py create mode 100644 addons/website_certification/security/ir.model.access.csv create mode 100644 addons/website_certification/views/website_certification_templates.xml create mode 100644 addons/website_certification/views/website_certification_views.xml diff --git a/addons/website_certification/__init__.py b/addons/website_certification/__init__.py new file mode 100644 index 00000000000..2a6cb8bee84 --- /dev/null +++ b/addons/website_certification/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY 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 . +# +############################################################################## + +import certification +import controllers diff --git a/addons/website_certification/__openerp__.py b/addons/website_certification/__openerp__.py new file mode 100644 index 00000000000..041014646fe --- /dev/null +++ b/addons/website_certification/__openerp__.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY 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 . +# +############################################################################## + +{ + 'name': 'Certified People', + 'category': 'Website', + 'summary': 'Display your network of certified people on your website', + 'version': '1.0', + 'author': 'OpenERP S.A.', + 'depends': ['marketing', 'website'], + 'description': """ + Display your network of certified people on your website + """, + 'data': [ + 'security/ir.model.access.csv', + 'views/website_certification_views.xml', + 'views/website_certification_templates.xml', + ], + 'installable': True, +} diff --git a/addons/website_certification/certification.py b/addons/website_certification/certification.py new file mode 100644 index 00000000000..48636e027f7 --- /dev/null +++ b/addons/website_certification/certification.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY 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 osv, fields + + +class certification_type(osv.Model): + _name = 'certification.type' + _order = 'name ASC' + _columns = { + 'name': fields.char("Certification Type", required=True) + } + + +class certification_certification(osv.Model): + _name = 'certification.certification' + _order = 'certification_date DESC' + _columns = { + 'partner_id': fields.many2one('res.partner', string="Partner", required=True), + 'type_id': fields.many2one('certification.type', string="Certification", required=True), + 'certification_date': fields.date("Certification Date", required=True), + 'certification_score': fields.char("Certification Score", required=True), + 'certification_hidden_score': fields.boolean("Hide score on website?") + } diff --git a/addons/website_certification/controllers/__init__.py b/addons/website_certification/controllers/__init__.py new file mode 100644 index 00000000000..672df6ec1f9 --- /dev/null +++ b/addons/website_certification/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY 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 . +# +############################################################################## + +import main diff --git a/addons/website_certification/controllers/main.py b/addons/website_certification/controllers/main.py new file mode 100644 index 00000000000..75fe9174760 --- /dev/null +++ b/addons/website_certification/controllers/main.py @@ -0,0 +1,50 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY 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.addons.web import http +from openerp.addons.web.http import request + + +class WebsiteCertifiedPartners(http.Controller): + + @http.route(['/certifications', + '/certifications/'], type='http', auth='public', + website=True, multilang=True) + def certified_partners(self, cert_type=None, **post): + cr, uid, context = request.cr, request.uid, request.context + certification_obj = request.registry['certification.certification'] + cert_type_obj = request.registry['certification.type'] + + domain = [] + if cert_type: + domain.append(('type_id', '=', cert_type.id)) + + certifications_ids = certification_obj.search(cr, uid, domain, context=context) + certifications = certification_obj.browse(cr, uid, certifications_ids, context=context) + types = cert_type_obj.browse(cr, uid, cert_type_obj.search(cr, uid, [], context=context), context=context) + data = { + 'certifications': certifications, + 'types': types + } + + # ici selectionner les partners certifies uniquement + return request.website.render("website_certification.certified_partners", data) diff --git a/addons/website_certification/security/ir.model.access.csv b/addons/website_certification/security/ir.model.access.csv new file mode 100644 index 00000000000..a297b053d26 --- /dev/null +++ b/addons/website_certification/security/ir.model.access.csv @@ -0,0 +1,7 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_certifications_public,certification.certification public,model_certification_certification,base.group_public,1,0,0,0 +access_certifications_types_public,certification.type public,model_certification_type,base.group_public,1,0,0,0 +access_certifications_users,certification.certification users,model_certification_certification,base.group_user,1,0,0,0 +access_certifications_types_users,certification.type users,model_certification_type,base.group_user,1,0,0,0 +access_certifications_marketing,certification.certification marketing,model_certification_certification,marketing.group_marketing_user,1,1,1,1 +access_certifications_types_marketing,certification.type marketing,model_certification_type,marketing.group_marketing_user,1,1,1,1 diff --git a/addons/website_certification/views/website_certification_templates.xml b/addons/website_certification/views/website_certification_templates.xml new file mode 100644 index 00000000000..eaacdea22ba --- /dev/null +++ b/addons/website_certification/views/website_certification_templates.xml @@ -0,0 +1,42 @@ + + + + + + \ No newline at end of file diff --git a/addons/website_certification/views/website_certification_views.xml b/addons/website_certification/views/website_certification_views.xml new file mode 100644 index 00000000000..b732df1a3e1 --- /dev/null +++ b/addons/website_certification/views/website_certification_views.xml @@ -0,0 +1,58 @@ + + + + + view.certification.certification.tree + certification.certification + + + + + + + + + + + + view.certification.certification.form + certification.certification + +
+ + + + + + + + + +
+
+
+ + view.certification.certification.search + certification.certification + + + + + + + + + + + + + Certifications + certification.certification + form + tree,form + + + + +
+
\ No newline at end of file