3 import openerp.http as http
4 from openerp.http import request
5 import openerp.addons.web.controllers.main as webmain
9 class meeting_invitation(http.Controller):
11 @http.route('/calendar/meeting/accept', type='http', auth="calendar")
12 def accept(self, db, token, action, id, **kwargs):
13 registry = openerp.modules.registry.RegistryManager.get(db)
14 attendee_pool = registry.get('calendar.attendee')
15 with registry.cursor() as cr:
16 attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token', '=', token), ('state', '!=', 'accepted')])
18 attendee_pool.do_accept(cr, openerp.SUPERUSER_ID, attendee_id)
19 return self.view(db, token, action, id, view='form')
21 @http.route('/calendar/meeting/decline', type='http', auth="calendar")
22 def declined(self, db, token, action, id):
23 registry = openerp.modules.registry.RegistryManager.get(db)
24 attendee_pool = registry.get('calendar.attendee')
25 with registry.cursor() as cr:
26 attendee_id = attendee_pool.search(cr, openerp.SUPERUSER_ID, [('access_token', '=', token), ('state', '!=', 'declined')])
28 attendee_pool.do_decline(cr, openerp.SUPERUSER_ID, attendee_id)
29 return self.view(db, token, action, id, view='form')
31 @http.route('/calendar/meeting/view', type='http', auth="calendar")
32 def view(self, db, token, action, id, view='calendar'):
33 registry = openerp.modules.registry.RegistryManager.get(db)
34 meeting_pool = registry.get('calendar.event')
35 attendee_pool = registry.get('calendar.attendee')
36 partner_pool = registry.get('res.partner')
37 with registry.cursor() as cr:
38 attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token', '=', token)], [])
40 if attendee and attendee[0] and attendee[0].get('partner_id'):
41 partner_id = int(attendee[0].get('partner_id')[0])
42 tz = partner_pool.read(cr, openerp.SUPERUSER_ID, partner_id, ['tz'])['tz']
46 attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id, dict(tz=tz))
49 attendee_data['current_attendee'] = attendee[0]
51 values = dict(init="s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data)))
52 return request.render('web.webclient_bootstrap', values)
54 # Function used, in RPC to check every 5 minutes, if notification to do for an event or not
55 @http.route('/calendar/notify', type='json', auth="none")
57 registry = request.registry
58 uid = request.session.uid
59 context = request.session.context
60 with registry.cursor() as cr:
61 res = registry.get("calendar.alarm_manager").get_next_notif(cr, uid, context=context)
64 @http.route('/calendar/notify_ack', type='json', auth="none")
65 def notify_ack(self, type=''):
66 registry = request.registry
67 uid = request.session.uid
68 context = request.session.context
69 with registry.cursor() as cr:
70 res = registry.get("res.partner")._set_calendar_last_notif_ack(cr, uid, context=context)