From 8901ad8fe683363dee031dd4bcb8c1311ae6ff75 Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Wed, 9 Oct 2013 12:49:37 +0530 Subject: [PATCH] [REM]: Remove portal_calernder module and add qweb template to alloe user to accept and decline an invitation without login bzr revid: aja@tinyerp.com-20131009071937-z22z71tab13k7q05 --- addons/base_calendar/controllers/main.py | 41 +++++++++------- addons/base_calendar/crm_meeting.py | 32 ++++--------- addons/base_calendar/crm_meeting_data.xml | 2 +- .../static/src/css/base_calender.css | 48 +++++++++++++++++++ .../static/src/js/base_calendar.js | 13 +++-- .../static/src/xml/base_calender.xml | 29 ++++++++++- addons/portal_calendar/__init__.py | 20 -------- addons/portal_calendar/__openerp__.py | 46 ------------------ .../portal_calendar/portal_calender_view.xml | 21 -------- .../security/ir.model.access.csv | 5 -- .../security/portal_security.xml | 11 ----- 11 files changed, 117 insertions(+), 151 deletions(-) delete mode 100644 addons/portal_calendar/__init__.py delete mode 100644 addons/portal_calendar/__openerp__.py delete mode 100644 addons/portal_calendar/portal_calender_view.xml delete mode 100644 addons/portal_calendar/security/ir.model.access.csv delete mode 100644 addons/portal_calendar/security/portal_security.xml diff --git a/addons/base_calendar/controllers/main.py b/addons/base_calendar/controllers/main.py index 846d004c8c5..e115def3cb1 100644 --- a/addons/base_calendar/controllers/main.py +++ b/addons/base_calendar/controllers/main.py @@ -4,41 +4,50 @@ import openerp import openerp.addons.web.http as http from openerp.addons.web.http import request import openerp.addons.web.controllers.main as webmain -SUPERUSER_ID = 1 +import json class meetting_invitation(http.Controller): - + @http.route('/meeting_invitation/accept', type='http', auth="none") def accept(self, db, token, action, id): - # http://hostname:8069/meeting_invitation/accept/id=1&token=&db= + # http://hostname:8069/meeting_invitation/accept?db=#token=&action=&id= registry = openerp.modules.registry.RegistryManager.get(db) attendee_pool = registry.get('calendar.attendee') with registry.cursor() as cr: - attendee_ids = attendee_pool.search(cr, SUPERUSER_ID, [('access_token','=',token)]) - attendee_pool.do_accept(cr, SUPERUSER_ID, attendee_ids) - return self.view(db, action, id, view='form') - - + attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token','=',token)]) + if attendee_id: + attendee_pool.do_accept(cr, openerp.SUPERUSER_ID, attendee_id) + return self.view(db, token, action, id, view='form') + @http.route('/meeting_invitation/decline', type='http', auth="none") def declined(self, db, token, action, id): - # http://hostname:8069/meeting_invitation/accept/id=1&token=&db= + # http://hostname:8069/meeting_invitation/decline?db=#token=&action=&id= registry = openerp.modules.registry.RegistryManager.get(db) attendee_pool = registry.get('calendar.attendee') with registry.cursor() as cr: - attendee_ids = attendee_pool.search(cr, SUPERUSER_ID, [('access_token','=',token)]) - attendee_pool.do_decline(cr, SUPERUSER_ID, attendee_ids) - return self.view(db, action, id, view='form') - + attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token','=',token)]) + if attendee_id: + attendee_pool.do_decline(cr, openerp.SUPERUSER_ID, attendee_id) + return self.view(db, token, action, id, view='form') + @http.route('/meeting_invitation/view', type='http', auth="none") - def view(self, db, action, id, view='calendar'): - # http://hostname:8069/meeting_invitation/view/id=1&token=&db=&view= + def view(self, db, token, action, id, view='calendar'): + # http://hostname:8069/meeting_invitation/view?db=#token=&action=&id= + registry = openerp.modules.registry.RegistryManager.get(db) + meeting_pool = registry.get('crm.meeting') + attendee_pool = registry.get('calendar.attendee') + with registry.cursor() as cr: + attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id); + attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token','=',token)],[]) + if attendee: + attendee_data['current_attendee'] = attendee[0] js = "\n ".join('' % i for i in webmain.manifest_list('js', db=db)) css = "\n ".join('' % i for i in webmain.manifest_list('css',db=db)) return webmain.html_template % { 'js': js, 'css': css, 'modules': simplejson.dumps(webmain.module_boot(db)), - 'init': 's.base_calendar.event("%s", "%s", "%s", "%s");' % (db, action, id, view), + 'init': "s.base_calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, view, json.dumps(attendee_data)), } diff --git a/addons/base_calendar/crm_meeting.py b/addons/base_calendar/crm_meeting.py index d04e6fc5cbe..222abb8c890 100644 --- a/addons/base_calendar/crm_meeting.py +++ b/addons/base_calendar/crm_meeting.py @@ -28,6 +28,7 @@ from base_calendar import get_real_ids, base_calendar_id2real_id from datetime import datetime, timedelta, date import pytz from openerp import tools +import openerp # # crm.meeting is defined here so that it may be used by modules other than crm, @@ -192,35 +193,20 @@ class crm_meeting(osv.Model): del context['default_date'] return super(crm_meeting, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, **kwargs) - def do_decline(self, cr, uid, ids, context=None): - attendee_pool = self.pool.get('calendar.attendee') - for meeting_id in ids: - attendee = self._find_user_attendee(cr, uid, meeting_id, context) - if attendee: - if attendee.state != 'declined': - self.message_post(cr, uid, meeting_id, body=_(("%s has declined invitation") % (attendee.cn)), context=context) - attendee_pool.write(cr, uid, attendee.id, {'state': 'declined'}, context) - return True - - def do_accept(self, cr, uid, ids, context=None): - attendee_pool = self.pool.get('calendar.attendee') - for meeting_id in ids: - attendee = self._find_user_attendee(cr, uid, meeting_id, context) - if attendee: - if attendee.state != 'accepted': - self.message_post(cr, uid, meeting_id, body=_(("%s has accepted invitation") % (attendee.cn)), context=context) - attendee_pool.write(cr, uid, attendee.id, {'state': 'accepted'}, context) - return True - def get_attendee(self, cr, uid, meeting_id, context=None): att = [] + invitation = {'meeting': {}, 'attendee': []} attendee_pool = self.pool.get('calendar.attendee') - for attendee in self.browse(cr,uid,int(meeting_id),context).attendee_ids: + invitation['logo'] = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.logo.replace('\n','\\n') + meeting = self.browse(cr, uid, int(meeting_id), context) + invitation['meeting'] = {'event':meeting.name,'organizer': meeting.organizer, 'where': meeting.location,'when':meeting.event_time} + for attendee in meeting.attendee_ids: att.append({'name':attendee.cn,'status': attendee.state}) - return att + invitation['attendee'] = att + return invitation def get_day(self, cr, uid, ids, time= None, context=None): - rec = self.browse(cr, uid, ids,context=context)[0] + rec = self.browse(cr, uid, ids, context=context)[0] date = datetime.strptime(rec.date,'%Y-%m-%d %H:%M:%S') if time == 'day': res = str(date.day) diff --git a/addons/base_calendar/crm_meeting_data.xml b/addons/base_calendar/crm_meeting_data.xml index 725dc08d934..61d17828e7f 100644 --- a/addons/base_calendar/crm_meeting_data.xml +++ b/addons/base_calendar/crm_meeting_data.xml @@ -119,7 +119,7 @@ Decline
- --
Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail directly in OpenERP. + --
Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail directly in OpenERP.
diff --git a/addons/base_calendar/static/src/css/base_calender.css b/addons/base_calendar/static/src/css/base_calender.css index 9e647ea8e44..3a3956ef985 100644 --- a/addons/base_calendar/static/src/css/base_calender.css +++ b/addons/base_calendar/static/src/css/base_calender.css @@ -16,3 +16,51 @@ background : url(/web/static/src/img/icons/gtk-no.png) no-repeat; background-size : 11px 11px; } + +.cal_meeting { + font-size : 24px; + font-style: bold; + text-align : justify; + color : #8A89BA; +} +.cal_lable { + width: 50px; + color : #808080; +} +.invitation_block { + padding : 50px 0 0 30px; + font-size : 14px; + background : #f9f9f9; +} +.attendee_accepted { + background : url(/web/static/src/img/icons/gtk-apply.png) no-repeat; + background-size : 15px 15px; + padding-left: 20px; +} +.attendee_declined { + background : url(/web/static/src/img/icons/gtk-cancel.png) no-repeat; + background-size : 15px 15px; + padding-left: 20px; +} +.event_status{ + border : 1px solid; + height : 20px; + width : auto; + background: #808080; + color : #FFFFFF; + padding: 5px 10px; + width: 400px; +} +.cal_inline{ + display: inline; +} +.cal_tag { + padding-right : 10px; + font-style : italic; + font-size : 17px; + vertical-align:bottom; +} +.cal_image { + height: 30px; + width : 100px; +} diff --git a/addons/base_calendar/static/src/js/base_calendar.js b/addons/base_calendar/static/src/js/base_calendar.js index 6527bbd7dc7..434cf75416a 100644 --- a/addons/base_calendar/static/src/js/base_calendar.js +++ b/addons/base_calendar/static/src/js/base_calendar.js @@ -5,25 +5,24 @@ instance.base_calendar = {} instance.base_calendar.invitation = instance.web.Widget.extend({ - init: function(parent, db, action, id, view) { + init: function(parent, db, action, id, view, attendee_data) { this._super(); this.db = db; this.action = action; this.id = id; this.view = view; + this.attendee_data = attendee_data; }, start: function() { var self = this; if(instance.session.session_is_valid(self.db)) { self.redirect_meeting_view(self.db,self.action,self.id,self.view); } else { - new instance.web.Model("crm.meeting").call('get_attendee',[self.id]).then(function(res){ - self.open_invitation_form(res); - }); + self.open_invitation_form(self.attendee_data); } }, open_invitation_form : function(invitation){ - this.$el.html(QWeb.render('invitation_view', {'widget': invitation})); + this.$el.html(QWeb.render('invitation_view', {'invitation': JSON.parse(invitation)})); }, redirect_meeting_view : function(db, action, meeting_id, view){ var self = this; @@ -175,9 +174,9 @@ instance.base_calendar = {} 'Many2Many_invite' : 'instance.web.form.Many2Many_invite', }); - instance.base_calendar.event = function (db, action, id, view) { + instance.base_calendar.event = function (db, action, id, view, attendee_data) { instance.session.session_bind(instance.session.origin).done(function () { - new instance.base_calendar.invitation(null,db,action,id,view).appendTo($("body").addClass('openerp')); + new instance.base_calendar.invitation(null,db,action,id,view,attendee_data).appendTo($("body").addClass('openerp')); }); } }; diff --git a/addons/base_calendar/static/src/xml/base_calender.xml b/addons/base_calendar/static/src/xml/base_calender.xml index 6d1ebd1811e..7ca725e6e3d 100644 --- a/addons/base_calendar/static/src/xml/base_calender.xml +++ b/addons/base_calendar/static/src/xml/base_calender.xml @@ -11,6 +11,33 @@ - Testttt +
()
+

Calendar

+
+ + + +
+ + + + + + + + + + + + + +
When:
Where:
Who + : - Organizer + +
+ +
+
+
diff --git a/addons/portal_calendar/__init__.py b/addons/portal_calendar/__init__.py deleted file mode 100644 index 71376240d03..00000000000 --- a/addons/portal_calendar/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- 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 deleted file mode 100644 index cb13ade1abd..00000000000 --- a/addons/portal_calendar/__openerp__.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- 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 deleted file mode 100644 index 69732bb6399..00000000000 --- a/addons/portal_calendar/portal_calender_view.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - 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 deleted file mode 100644 index 9e3852aa9cf..00000000000 --- a/addons/portal_calendar/security/ir.model.access.csv +++ /dev/null @@ -1,5 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_meeting,portal_meeting,base_calendar.model_crm_meeting,portal.group_portal,1,0,0,0 -access_anonymous_meeting,anonymous_meeting,base_calendar.model_crm_meeting,portal.group_anonymous,1,0,0,0 -access_anonymous_attendee,anonymous_attendee,base_calendar.model_calendar_attendee,portal.group_anonymous,1,0,0,0 -access_anonymous_event,anonymous_event,base_calendar.model_calendar_event,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 deleted file mode 100644 index 9949951306e..00000000000 --- a/addons/portal_calendar/security/portal_security.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Meeting: portal and anonymous users: public only - - [('class', '=', 'public')] - - - -