You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

16 lines
586 B

from odoo import http
from odoo.http import request
from werkzeug.exceptions import Forbidden
class WebsiteMacavracShiftController(http.Controller):
@http.route("/shift/<int:shift_id>/unsubscribe", auth="user", website=True)
def unsubscribe_to_shift(self, shift_id=-1, **kw):
shift = request.env["beesdoo.shift.shift"].sudo().browse(shift_id)
# Get current user
if request.env.user.partner_id != shift.worker_id or not shift.can_unsubscribe:
raise Forbidden()
shift.worker_id = False
return request.redirect(kw["nexturl"])