[ADD] website_certification: new module to display certificated people on website

bzr revid: rim@openerp.com-20140418125043-mhe8u8f18pov0nce
This commit is contained in:
Richard Mathot (OpenERP) 2014-04-18 14:50:43 +02:00
parent 6f4efd45bb
commit 9a858f7daa
8 changed files with 283 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import certification
import controllers

View File

@ -0,0 +1,38 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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,
}

View File

@ -0,0 +1,43 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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?")
}

View File

@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
import main

View File

@ -0,0 +1,50 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://www.openerp.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.addons.web import http
from openerp.addons.web.http import request
class WebsiteCertifiedPartners(http.Controller):
@http.route(['/certifications',
'/certifications/<model("certification.type"):cert_type>'], 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)

View File

@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_certifications_public certification.certification public model_certification_certification base.group_public 1 0 0 0
3 access_certifications_types_public certification.type public model_certification_type base.group_public 1 0 0 0
4 access_certifications_users certification.certification users model_certification_certification base.group_user 1 0 0 0
5 access_certifications_types_users certification.type users model_certification_type base.group_user 1 0 0 0
6 access_certifications_marketing certification.certification marketing model_certification_certification marketing.group_marketing_user 1 1 1 1
7 access_certifications_types_marketing certification.type marketing model_certification_type marketing.group_marketing_user 1 1 1 1

View File

@ -0,0 +1,42 @@
<?xml version='1.0' encoding='utf-8'?>
<openerp>
<data>
<template id="certified_partners" name="Certified People">
<t t-call="website.layout">
<div id="wrap">
<div class="oe_structure"/>
<div class="container">
<div class="row">
<h1>Certified People</h1>
<div class="well">Filter by certification type:
<a href="/certifications"><span class="badge">all</span></a>
<t t-foreach="types" t-as="t">
<a t-att-href="'/certifications/%s' % slug(t)"><span class="badge" t-field="t.name" /></a>
</t>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead><tr>
<th>Name</th>
<th>Date</th>
<th>Type</th>
<th>Score</th>
</tr></thead>
<tbody>
<tr t-foreach="certifications" t-as="c">
<td><span t-field="c.partner_id"/></td>
<td><span t-field="c.certification_date"/></td>
<td><span t-field="c.type_id.name"/></td>
<td><t t-if="c.certification_hidden_score == False"><span t-field="c.certification_score"/></t></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="oe_structure"/>
</div>
</t>
</template>
</data>
</openerp>

View File

@ -0,0 +1,58 @@
<?xml version='1.0' encoding='utf-8'?>
<openerp>
<data>
<record model="ir.ui.view" id="certification_certification_tree">
<field name="name">view.certification.certification.tree</field>
<field name="model">certification.certification</field>
<field name="arch" type="xml">
<tree string="Granted Certifications">
<field name="partner_id" />
<field name="type_id" />
<field name="certification_date" />
<field name="certification_score" />
<field name="certification_hidden_score" />
</tree>
</field>
</record>
<record model="ir.ui.view" id="certification_certification_form">
<field name="name">view.certification.certification.form</field>
<field name="model">certification.certification</field>
<field name="arch" type="xml">
<form string="Granted Certification" version="7.0">
<sheet>
<group nolabel="1">
<field name="partner_id" />
<field name="type_id" />
<field name="certification_date" />
<field name="certification_score" />
<field name="certification_hidden_score" />
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="certification_certification_search">
<field name="name">view.certification.certification.search</field>
<field name="model">certification.certification</field>
<field name="arch" type="xml">
<search string="Search Certification">
<field name="partner_id" />
<field name="type_id" />
<group expand="0" string="Group By...">
<filter string="Partner" name="group_by_partner" domain="[]" context="{'group_by': 'partner_id'}"/>
<filter string="Type" name="group_by_type" domain="[]" context="{'group_by': 'type_id'}"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_certifications_list">
<field name="name">Certifications</field>
<field name="res_model">certification.certification</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="certification_certification_search"/>
</record>
<menuitem name="Certifications" id="menu_certifications" parent="base.marketing_menu" sequence="35" />
<menuitem name="Certifications" id="menu_certifications_list" action="action_certifications_list" parent="menu_certifications" sequence="1"/>
</data>
</openerp>