summaryrefslogtreecommitdiff
path: root/addons/calendar/controllers
diff options
context:
space:
mode:
authorLucas Lefèvre <lul@odoo.com>2019-12-10 09:38:43 +0100
committerLucas Lefèvre <lul@odoo.com>2020-04-09 10:56:37 +0200
commit7159f657a009e461ffc16408db40066b901885d1 (patch)
tree940953b37a7ac190de3f3da055d865d382cab100 /addons/calendar/controllers
parenta27afdb5434166c3ea48c18ccfba9e8245d18e62 (diff)
[REF] calendar: Refactor calendar attendees management
This commit refactors the event attendees and notifications according to the recurring event refactoring. Some (very) basic reminder tests are also added. Task 2126717 PR #42031 PR Enterprise odoo/enterprise#8006
Diffstat (limited to 'addons/calendar/controllers')
-rw-r--r--addons/calendar/controllers/main.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/addons/calendar/controllers/main.py b/addons/calendar/controllers/main.py
index cfecfb96345..11ca7675daf 100644
--- a/addons/calendar/controllers/main.py
+++ b/addons/calendar/controllers/main.py
@@ -24,6 +24,32 @@ class CalendarController(http.Controller):
attendee.do_accept()
return self.view(db, token, action, id, view='form')
+ @http.route('/calendar/recurrence/accept', type='http', auth="calendar")
+ def accept_recurrence(self, db, token, action, id, **kwargs):
+ # LUL TODO db required?
+ attendee = request.env['calendar.attendee'].sudo().search([('access_token', '=', token), ('state', '!=', 'accepted')])
+ if attendee:
+ attendees = request.env['calendar.attendee'].sudo().search([
+ ('event_id', 'in', attendee.event_id.recurrence_id.calendar_event_ids.ids),
+ ('partner_id', '=', attendee.partner_id.id),
+ ('state', '!=', 'accepted'),
+ ])
+ attendees.do_accept()
+ return self.view(db, token, action, id, view='form')
+
+ @http.route('/calendar/recurrence/decline', type='http', auth="calendar")
+ def decline_recurrence(self, db, token, action, id, **kwargs):
+ # LUL TODO db required?
+ attendee = request.env['calendar.attendee'].sudo().search([('access_token', '=', token), ('state', '!=', 'declined')])
+ if attendee:
+ attendees = request.env['calendar.attendee'].sudo().search([
+ ('event_id', 'in', attendee.event_id.recurrence_id.calendar_event_ids.ids),
+ ('partner_id', '=', attendee.partner_id.id),
+ ('state', '!=', 'declined'),
+ ])
+ attendees.do_decline()
+ return self.view(db, token, action, id, view='form')
+
@http.route('/calendar/meeting/decline', type='http', auth="calendar")
def declined(self, db, token, action, id):
registry = registry_get(db)