PURPOSE Overall cleaning of subscription and exclusion management code from portal. This code comes mainly from v12 and can now benefit from cleaning and update. SPECIFICATIONS Rename route parameters to be more clear about their usage. Notably res_id is better labelled document_id, token is a hash_token, ... Update legacy to still support old routes. Task-2669037 (Mass Mailing: Refactor js/portal for subscription) Part-of: odoo/odoo#86084
22 lines
776 B
Python
22 lines
776 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import werkzeug
|
|
|
|
from odoo import http
|
|
from odoo.http import request
|
|
|
|
|
|
class MailingLegacy(http.Controller):
|
|
""" Retro compatibility layer for legacy endpoint"""
|
|
|
|
@http.route(['/mail/mailing/<int:mailing_id>/unsubscribe'], type='http', website=True, auth='public')
|
|
def mailing_unsubscribe(self, mailing_id, email=None, res_id=None, token="", **post):
|
|
""" Old route, using mail/mailing prefix, and outdated parameter names """
|
|
params = werkzeug.urls.url_encode(
|
|
dict(**post, document_id=res_id, email=email, hash_token=token)
|
|
)
|
|
return request.redirect(
|
|
f'/mailing/{mailing_id}/unsubscribe?{params}'
|
|
)
|