-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] beesdoo_shift_website_unsubscribe: add module
Add module to allow to unsubscribe from the portal X hour before the shift starts
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters