Browse Source

Merge PR #54 into 13.0

Signed-off-by pedrobaeza
pull/59/head
OCA-git-bot 4 years ago
parent
commit
c13a826a32
  1. 13
      privacy_consent/controllers/main.py

13
privacy_consent/controllers/main.py

@ -5,29 +5,18 @@ from datetime import datetime
from werkzeug.exceptions import NotFound from werkzeug.exceptions import NotFound
from odoo import SUPERUSER_ID
from odoo.http import Controller, request, route from odoo.http import Controller, request, route
from odoo.addons.web.controllers.main import ensure_db
class ConsentController(Controller): class ConsentController(Controller):
@route( @route(
"/privacy/consent/<any(accept,reject):choice>/<int:consent_id>/<token>", "/privacy/consent/<any(accept,reject):choice>/<int:consent_id>/<token>",
type="http", type="http",
auth="none",
auth="public",
website=True, website=True,
) )
def consent(self, choice, consent_id, token, *args, **kwargs): def consent(self, choice, consent_id, token, *args, **kwargs):
"""Process user's consent acceptance or rejection.""" """Process user's consent acceptance or rejection."""
ensure_db()
try:
# If there's a website, we need a user to render the template
request.uid = request.website.user_id.id
except AttributeError:
# If there's no website, be root if there's no UID
if not request.uid:
request.uid = SUPERUSER_ID
consent = ( consent = (
request.env["privacy.consent"] request.env["privacy.consent"]
.with_context(subject_answering=True) .with_context(subject_answering=True)

Loading…
Cancel
Save