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)], [])
+ # 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 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
+ # 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))
- attendee_data = meeting_pool.get_attendee(cr, openerp.SUPERUSER_ID, id, dict(tz=tz))
-
- if attendee:
- attendee_data['current_attendee'] = attendee[0]
-
- 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")
diff --git a/addons/calendar/static/src/js/base_calendar.js b/addons/calendar/static/src/js/base_calendar.js
index 954371654d4..b3f5c5df8af 100644
--- a/addons/calendar/static/src/js/base_calendar.js
+++ b/addons/calendar/static/src/js/base_calendar.js
@@ -221,7 +221,7 @@ WebClient.include({
show_application: function() {
return this._super.apply(this, arguments).then(this.check_notifications.bind(this));
},
- //Override addons/web/static/src/js/chrome.js
+ //Override addons/web/static/src/js/chrome.js
// FIXME: on_logout is no longer used
on_logout: function() {
this._super();
@@ -243,20 +243,7 @@ var Many2ManyAttendee = FieldMany2ManyTags.extend({
},
});
-function showCalendarInvitation(db, action, id, view, attendee_data) {
- session.session_bind(session.origin).then(function () {
- if (session.session_is_valid(db) && session.username !== "anonymous") {
- window.location.href = _.str.sprintf('/web?db=%s#id=%s&view_type=form&model=calendar.event', db, id);
- } else {
- $("body").prepend(QWeb.render('CalendarInvitation', {attendee_data: JSON.parse(attendee_data)}));
- }
- });
-}
-
core.form_widget_registry.add('many2manyattendee', Many2ManyAttendee);
-return {
- showCalendarInvitation: showCalendarInvitation,
-};
});
diff --git a/addons/calendar/static/src/xml/base_calendar.xml b/addons/calendar/static/src/xml/base_calendar.xml
index 0cd9022fdec..1aa2bcb8b2f 100644
--- a/addons/calendar/static/src/xml/base_calendar.xml
+++ b/addons/calendar/static/src/xml/base_calendar.xml
@@ -28,40 +28,4 @@
-
-
-
(
)
-
- Yes I'm going.
- No I'm not going.
-
-
-
-

-
-
-
Calendar Invitation
-
-
-
-
- | When |
- |
-
-
- | Where |
- |
-
-
- | Who |
-
-
- |
-
-
-
diff --git a/addons/calendar/views/calendar.xml b/addons/calendar/views/calendar.xml
index 24b8fb7e4bf..7929fce158e 100644
--- a/addons/calendar/views/calendar.xml
+++ b/addons/calendar/views/calendar.xml
@@ -6,4 +6,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
Calendar Invitation
+
+
+
+
+
+ Yes I'm going.
+ No I'm not going.
+
+
+
+
+
+ | Invitation for |
+ () |
+
+
+ | Date |
+ |
+
+
+ | Location |
+ |
+
+
+ | Attendees |
+
+
+ |
+
+
+
+
+
+
+
+
+