If you register online on a free event, there is an access rights error when trying to download the ICS file if you are connectd with public user. `if not event` part is pointless, if event cannot be resolved, @http.route would return a 404 anyway. `if not event.registration_ids` does not make sense from a functional point of view: there is no problem in generating an .ics file for a public event that has no registrations (yet) and the button we use to generate the .ics file is displayed after the registration anyway. opw-2066847 closes odoo/odoo#37012 X-origin-commit: f4ca5897df9295b684bcbfcafd98fbde2f8bf673 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
22 lines
806 B
Python
22 lines
806 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from werkzeug.exceptions import NotFound
|
|
|
|
from odoo.http import Controller, request, route, content_disposition
|
|
|
|
|
|
class EventController(Controller):
|
|
|
|
@route(['''/event/<model("event.event", "[('state', 'in', ('confirm', 'done'))]"):event>/ics'''], type='http', auth="public")
|
|
def event_ics_file(self, event, **kwargs):
|
|
files = event._get_ics_file()
|
|
if not event.id in files:
|
|
return NotFound()
|
|
content = files[event.id]
|
|
return request.make_response(content, [
|
|
('Content-Type', 'application/octet-stream'),
|
|
('Content-Length', len(content)),
|
|
('Content-Disposition', content_disposition('%s.ics' % event.name))
|
|
])
|