From bba2e39fb8a4443eb80c570bf8b8984b64f6fe7c Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 27 Nov 2015 13:14:47 +0100 Subject: [PATCH] [FIX] calendar: redirection after invitation email When accepting/declining a calendar event invitation received by mail, we landed on an empty gray webclient. The confirmation page had been dropped with passage to new JS API / new calendar / new webclient. Previous mechanism had been reimplemented: custom web client with event information/confirmation if the user is not connected or redirection to the event form view if the user is connected. + FIX manyattendeetag : the status circle did not turn red when an user declined the invitation. --- addons/calendar/controllers/main.py | 8 +++- .../calendar/static/src/js/base_calendar.js | 15 +++++++ addons/calendar/static/src/less/calendar.less | 41 +++++++++++++++++++ .../calendar/static/src/xml/base_calendar.xml | 37 +++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/addons/calendar/controllers/main.py b/addons/calendar/controllers/main.py index 770c73bd41c..afe85209f03 100644 --- a/addons/calendar/controllers/main.py +++ b/addons/calendar/controllers/main.py @@ -48,7 +48,13 @@ class meeting_invitation(http.Controller): if attendee: attendee_data['current_attendee'] = attendee[0] - values = dict(init="s.calendar.event('%s', '%s', '%s', '%s' , '%s');" % (db, action, id, 'form', json.dumps(attendee_data))) + 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) # Function used, in RPC to check every 5 minutes, if notification to do for an event or not diff --git a/addons/calendar/static/src/js/base_calendar.js b/addons/calendar/static/src/js/base_calendar.js index 7139a0d61d1..b28f6308328 100644 --- a/addons/calendar/static/src/js/base_calendar.js +++ b/addons/calendar/static/src/js/base_calendar.js @@ -8,6 +8,7 @@ var Dialog = require('web.Dialog'); var form_common = require('web.form_common'); var Model = require('web.DataModel'); var Notification = require('web.notification').Notification; +var session = require('web.session'); var WebClient = require('web.WebClient'); var widgets = require('web_calendar.widgets'); @@ -252,6 +253,20 @@ 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/less/calendar.less b/addons/calendar/static/src/less/calendar.less index b531a583145..e3c15136a00 100644 --- a/addons/calendar/static/src/less/calendar.less +++ b/addons/calendar/static/src/less/calendar.less @@ -35,6 +35,10 @@ &.needsAction { background-color: @odoo-brand-secondary; } + + &.declined { + background-color: @brand-danger; + } } .o_calendar_all_responsibles { @@ -60,3 +64,40 @@ margin-top: 10px; position: relative; } + +.o_calendar_invitation_page { + .o-flex(0, 0, auto); + width: 50%; + margin: 30px auto 0; + .o-webclient-padding(@top: 10px, @bottom: 10px); + background-color: @odoo-view-background-color; + + .o_logo { + width: 15%; + } + .o_event_title { + margin-left: 20%; + + h2 { + margin-top: 0; + } + } + .o_event_table { + clear: both; + margin: 15px 0 0; + + th { + padding-right: 15px; + } + ul { + padding-left: 0; + } + } + + .o_accepted { + color: @brand-success; + } + .o_declined { + color: @brand-danger; + } +} diff --git a/addons/calendar/static/src/xml/base_calendar.xml b/addons/calendar/static/src/xml/base_calendar.xml index e4dd5eca511..d01994de2e5 100644 --- a/addons/calendar/static/src/xml/base_calendar.xml +++ b/addons/calendar/static/src/xml/base_calendar.xml @@ -27,4 +27,41 @@ + +
+
+ () +
+ Yes I'm going. + No I'm not going. +
+
+ +
+

Calendar Invitation

+

+
+ + + + + + + + + + + + + +
When
Where
Who +
    +
  • + +
  • +
+
+