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.

15 lines
586 B

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