diff options
| author | Jérome Maes <jem@openerp.com> | 2016-06-17 16:26:09 +0200 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2016-06-20 16:19:32 +0200 |
| commit | cfb8e8700a501c47a5b3c1b7c8a0e9e58e417f58 (patch) | |
| tree | 510083656fd7e50212abe7085e1654997683827e /addons/calendar/controllers | |
| parent | 3cb64f517a54c56763f1fed16fc7234194167009 (diff) | |
[FIX] calendar: view meeting detail when not logged
Since the new QWeb engine, `groups` directives on template
rendered in a route with auth=none is simply ignored, since
all is done as SUPERUSER_ID, it was impossible to instanciate
the webclient to check if the session is valid and to display
meeting info or redirect to event form view.
It seems that we don't want to fix this because routes auth=none
are rare, and special. So it is not considered as a bug.
The fix for calendar is, however, to do redirection or template
rendering server side.
Diffstat (limited to 'addons/calendar/controllers')
| -rw-r--r-- | addons/calendar/controllers/main.py | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/addons/calendar/controllers/main.py b/addons/calendar/controllers/main.py index afe85209f03..0a8fa25bd78 100644 --- a/addons/calendar/controllers/main.py +++ b/addons/calendar/controllers/main.py @@ -4,6 +4,9 @@ import openerp.http as http from openerp.http import request import openerp.addons.web.controllers.main as webmain import json +import werkzeug + +from odoo.api import Environment class meeting_invitation(http.Controller): @@ -31,31 +34,27 @@ class meeting_invitation(http.Controller): @http.route('/calendar/meeting/view', type='http', auth="calendar") def view(self, db, token, action, id, view='calendar'): registry = openerp.modules.registry.RegistryManager.get(db) - meeting_pool = registry.get('calendar.event') - attendee_pool = registry.get('calendar.attendee') - partner_pool = registry.get('res.partner') with registry.cursor() as cr: - attendee = attendee_pool.search_read(cr, openerp.SUPERUSER_ID, [('access_token', '=', token)], []) - - if attendee and attendee[0] and attendee[0].get('partner_id'): - partner_id = int(attendee[0].get('partner_id')[0]) - tz = partner_pool.read(cr, openerp.SUPERUSER_ID, partner_id, ['tz'])['tz'] - else: - tz = False - - attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id, dict(tz=tz)) + # Since we are in auth=none, create an env with SUPERUSER_ID + env = Environment(cr, openerp.SUPERUSER_ID, {}) + attendee = env['calendar.attendee'].search([('access_token', '=', token)]) + timezone = attendee.partner_id.tz + event = env['calendar.event'].with_context(tz=timezone).browse(int(id)) - if attendee: - attendee_data['current_attendee'] = attendee[0] + # If user is logged, redirect to form view of event + # otherwise, display the simplifyed web page with event informations + if request.session.uid: + return werkzeug.utils.redirect('/web?db=%s#id=%s&view_type=form&model=calendar.event' % (db, id)) - values = dict( - init = """ - odoo.define('calendar.invitation_page', function (require) { - require('base_calendar.base_calendar').showCalendarInvitation('%s', '%s', '%s', '%s', '%s'); - }); - """ % (db, action, id, 'form', json.dumps(attendee_data)) - ) - return request.render('web.webclient_bootstrap', values) + # NOTE : calling render return a lazy response. The rendering result will be done when the + # cursor will be closed. So it is requried to call `flatten` to make the redering before + # existing the `with` clause + response = request.render('calendar.invitation_page_anonymous', { + 'event': event, + 'attendee': attendee, + }) + response.flatten() + return response # Function used, in RPC to check every 5 minutes, if notification to do for an event or not @http.route('/calendar/notify', type='json', auth="none") |
