[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
This commit is contained in:
parent
086dbfa5cf
commit
8901ad8fe6
|
@ -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('<script type="text/javascript" src="%s"></script>' % i for i in webmain.manifest_list('js', db=db))
|
||||
css = "\n ".join('<link rel="stylesheet" href="%s">' % 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)),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
<a style="padding: 8px 30px 8px 30px;border-radius: 6px;border: 1px solid #CCCCCC;background:#808080;text-decoration: none;color:#FFFFFF;" href="${ctx['base_url']}/meeting_invitation/decline?db=${ctx['dbname']}&token=${ctx['att_obj'].access_token}&action=${ctx['action_id']}&id=${object.id}">Decline</a>
|
||||
</div>
|
||||
<div>
|
||||
-- </br> Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail <a href="${ctx['base_url']}/meeting_invitation/view?db=${ctx['dbname']}&action=${ctx['action_id']}&id=${object.id}">directly in OpenERP.</a>
|
||||
-- </br> Sent by ${object.user_id.name} from ${object.user_id.company_id.name}. View this meeting detail <a href="${ctx['base_url']}/meeting_invitation/view?db=${ctx['dbname']}&token=${ctx['att_obj'].access_token}&action=${ctx['action_id']}&id=${object.id}">directly in OpenERP.</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,33 @@
|
|||
</t>
|
||||
</t>
|
||||
<t t-name="invitation_view">
|
||||
Testttt
|
||||
<div class="oe_right"><b><t t-esc="invitation['current_attendee'].cn"/> (<t t-esc="invitation['current_attendee'].email"/>)</b></div>
|
||||
<div class="oe_left"><img class="cal_inline cal_image" t-attf-src="data:image/png;base64,#{invitation['logo']}"/><p class="cal_tag cal_inline">Calendar</p></div>
|
||||
<div class="invitation_block">
|
||||
<t t-if="invitation['current_attendee'].state != 'needs-action'">
|
||||
<div class="event_status"><a t-attf-class="attendee_#{invitation['current_attendee'].state}"><b t-if="invitation['current_attendee'].state == 'accepted'">Yes I'm going.</b><b t-if="invitation['current_attendee'].state == 'declined'">No I'm not going.</b></a></div>
|
||||
</t>
|
||||
<div class="cal_meeting"><t t-esc="invitation['meeting'].event"/></div>
|
||||
<table calss="invitation_block">
|
||||
<tr>
|
||||
<td class="cal_lable">When</td>
|
||||
<td>: <t t-esc="invitation['meeting'].when"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cal_lable">Where</td>
|
||||
<td>: <t t-esc="invitation['meeting'].where or ''"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cal_lable">Who</td>
|
||||
<td>
|
||||
<span>: <t t-esc="invitation['meeting'].organizer"/> - <a class="cal_lable">Organizer</a></span>
|
||||
<t t-foreach="invitation['attendee']" t-as="att">
|
||||
<br/>
|
||||
<span class="cal_status"><a t-attf-class="oe_invitation #{att.status}"/><t t-esc="att.name"/></span>
|
||||
</t>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-TODAY OpenERP SA (<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/>.
|
||||
#
|
||||
##############################################################################
|
|
@ -1,46 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-TODAY OpenERP SA (<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': '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:
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--
|
||||
Override the original action to set another help field and/or
|
||||
another context field, more suited for portal members
|
||||
-->
|
||||
<record model="ir.actions.act_window" id="action_portal_meeting_view">
|
||||
<field name="name">Meetings</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">crm.meeting</field>
|
||||
<field name="view_mode">calendar,tree,form</field>
|
||||
<field name="help">There are no public meeting.</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Calendar" id="portal_company_meeting" parent="portal.portal_company"
|
||||
action="action_portal_meeting_view" sequence="30"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -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
|
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.rule" id="crm_meeting_portal_anonymous_rule">
|
||||
<field name="name">Meeting: portal and anonymous users: public only</field>
|
||||
<field name="model_id" ref="crm.model_crm_meeting"/>
|
||||
<field name="domain_force">[('class', '=', 'public')]</field>
|
||||
<field name="groups" eval="[(4, ref('portal.group_portal')), (4, ref('portal.group_anonymous'))]"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue