From 6cc461a352ba5dee9525c9750803f8b5eb5e12e3 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Tue, 1 Oct 2013 18:51:15 +0530 Subject: [PATCH] [ADD]: Module portal_calender : Allow an anonymous and portal user to see meetings bzr revid: aja@tinyerp.com-20131001132115-co24ucbc84b7sn1e --- .../security/calendar_security.xml | 1 + .../static/src/js/base_calendar.js | 17 ++++--- addons/portal_calendar/__init__.py | 20 ++++++++ addons/portal_calendar/__openerp__.py | 46 +++++++++++++++++++ .../portal_calendar/portal_calender_view.xml | 21 +++++++++ .../security/ir.model.access.csv | 3 ++ .../security/portal_security.xml | 11 +++++ 7 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 addons/portal_calendar/__init__.py create mode 100644 addons/portal_calendar/__openerp__.py create mode 100644 addons/portal_calendar/portal_calender_view.xml create mode 100644 addons/portal_calendar/security/ir.model.access.csv create mode 100644 addons/portal_calendar/security/portal_security.xml diff --git a/addons/base_calendar/security/calendar_security.xml b/addons/base_calendar/security/calendar_security.xml index aa5844f5de9..2a3ef490241 100644 --- a/addons/base_calendar/security/calendar_security.xml +++ b/addons/base_calendar/security/calendar_security.xml @@ -10,6 +10,7 @@ ['|',('attendee_ids.partner_id','=',user.partner_id.id),('attendee_ids','=',False)] + diff --git a/addons/base_calendar/static/src/js/base_calendar.js b/addons/base_calendar/static/src/js/base_calendar.js index 7212b496ac3..4d62b27a1ce 100644 --- a/addons/base_calendar/static/src/js/base_calendar.js +++ b/addons/base_calendar/static/src/js/base_calendar.js @@ -16,10 +16,10 @@ instance.base_calendar = {} }, start: function() { var self = this; - if (instance.session.session_is_valid(self.db)) { + if (instance.session.session_is_valid(self.db) && (this.view_type == 'calendar' || this.view_type == 'form' && this.session.username != 'anonymous')) { self.show_meeting(); - } else { - self.show_login() + }else { + self.show_login(); } }, show_login: function(action) { @@ -46,7 +46,7 @@ instance.base_calendar = {} }, show_meeting : function(){ var db = this.db; - var att_status = "do_decline"; + var att_status = false; var self = this; var reload_page = function(){ if(self.view_type === 'form'){ @@ -56,11 +56,16 @@ instance.base_calendar = {} return location.replace(_.str.sprintf('/?db=%s#view_type=%s&model=crm.meeting&action=%s',self.db,self.view_type,self.action)); } } - if(self.status === 'accepted'){att_status = "do_accept";} + if(self.status === 'accepted'){ + att_status = "do_accept"; + } + else if(self.status === 'declined'){ + att_status === "do_decline"; + } var calender_attendee = new instance.web.Model('calendar.attendee') return calender_attendee.get_func("search_read")([["id", "=", parseInt(this.token)]],['state']).done(function(res){ - if(res[0] && res[0]['state'] === "needs-action"){ + if(res[0] && res[0]['state'] === "needs-action" && att_status){ return calender_attendee.call(att_status,[[parseInt(self.token)]]).done(reload_page); } reload_page(); diff --git a/addons/portal_calendar/__init__.py b/addons/portal_calendar/__init__.py new file mode 100644 index 00000000000..71376240d03 --- /dev/null +++ b/addons/portal_calendar/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY OpenERP SA () +# +# 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 . +# +############################################################################## diff --git a/addons/portal_calendar/__openerp__.py b/addons/portal_calendar/__openerp__.py new file mode 100644 index 00000000000..cb13ade1abd --- /dev/null +++ b/addons/portal_calendar/__openerp__.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-TODAY OpenERP SA () +# +# 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': 'Portal Calender', + 'version': '0.1', + 'category': 'Tools', + 'complexity': 'easy', + 'description': """ +This module adds Calendar menu and features to your portal if Calendar and portal are installed. +========================================================================================== + """, + 'author': 'OpenERP SA', + 'depends': [ + 'base_calendar', + 'portal', + ], + 'data': [ + 'portal_calender_view.xml', + 'security/portal_security.xml', + 'security/ir.model.access.csv', + ], + 'installable': True, + 'auto_install': True, + 'category': 'Hidden', +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/portal_calendar/portal_calender_view.xml b/addons/portal_calendar/portal_calender_view.xml new file mode 100644 index 00000000000..69732bb6399 --- /dev/null +++ b/addons/portal_calendar/portal_calender_view.xml @@ -0,0 +1,21 @@ + + + + + + + Meetings + ir.actions.act_window + crm.meeting + calendar,tree,form + There are no public meeting. + + + + + + diff --git a/addons/portal_calendar/security/ir.model.access.csv b/addons/portal_calendar/security/ir.model.access.csv new file mode 100644 index 00000000000..8031b83d1a7 --- /dev/null +++ b/addons/portal_calendar/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_meeting,meeting,base_calendar.model_crm_meeting,portal.group_portal,1,0,0,0 +access_anonymous_meeting,meeting,base_calendar.model_crm_meeting,portal.group_anonymous,1,0,0,0 diff --git a/addons/portal_calendar/security/portal_security.xml b/addons/portal_calendar/security/portal_security.xml new file mode 100644 index 00000000000..9949951306e --- /dev/null +++ b/addons/portal_calendar/security/portal_security.xml @@ -0,0 +1,11 @@ + + + + + Meeting: portal and anonymous users: public only + + [('class', '=', 'public')] + + + +