From 19f3a47addf4c2310e7b5dee32a136699e6145ee Mon Sep 17 00:00:00 2001 From: Daniel Gergely Date: Wed, 1 Apr 2026 09:33:26 +0200 Subject: [PATCH 1/2] [T3087] FIX: redirect old child sponsor url - FIX: /child//sponsor is now redirected to the new /my2/new-sponsorship/ --- my_compassion/controllers/my_account.py | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/my_compassion/controllers/my_account.py b/my_compassion/controllers/my_account.py index 751a6a9a..e64aa661 100644 --- a/my_compassion/controllers/my_account.py +++ b/my_compassion/controllers/my_account.py @@ -20,6 +20,7 @@ from odoo.exceptions import UserError from odoo.http import local_redirect, request, route +from odoo.addons.http_routing.models.ir_http import slug from odoo.addons.portal.controllers.portal import CustomerPortal from odoo.addons.web.controllers.main import content_disposition @@ -251,6 +252,8 @@ def _create_magic_user_from_partner(partner): _, login, _ = res_users.signup(values=values, token=partner.signup_token) return login + ############################# REDIRECTS ################################ + @route(["/my", "/my/home"], type="http", auth="user", website=True) def home(self, redirect=None, **post): """ @@ -335,6 +338,30 @@ def redirect_old_my_information(self, form_id=None, privacy_policy=None, **kw): partner.legal_agreement_date = datetime.now() return request.render("my_compassion.my_information_page_template", values) + @route( + "/child//sponsor", + type="http", + auth="public", + website=True, + sitemap=False, + ) + def redirect_old_child_sponsor(self, child, **kw): + """ + This is a deprecated route of MyCompassion 1.0. + From MyCompassion 2.0, we ensured a proper redirection + for user using old links. + """ + # Extract model ID + child_slug = slug(child) + new_url = f"/my2/new-sponsorship/{child_slug}" + + # Extract and append any query parameters (like UTMs) + query_string = request.httprequest.query_string.decode("utf-8") + if query_string: + new_url = f"{new_url}?{query_string}" + + return request.redirect(new_url, code=301) + @route("/my/download/", type="http", auth="user", website=True) def download_file(self, source, **kw): """ From 40ea64a8be79127caaea3b35d2865b8b577bbe58 Mon Sep 17 00:00:00 2001 From: Daniel Gergely Date: Wed, 1 Apr 2026 11:32:43 +0200 Subject: [PATCH 2/2] [T3087] REFACTOR: GCA inspired slightly different approach --- my_compassion/controllers/my_account.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/my_compassion/controllers/my_account.py b/my_compassion/controllers/my_account.py index e64aa661..0185f236 100644 --- a/my_compassion/controllers/my_account.py +++ b/my_compassion/controllers/my_account.py @@ -339,21 +339,29 @@ def redirect_old_my_information(self, form_id=None, privacy_policy=None, **kw): return request.render("my_compassion.my_information_page_template", values) @route( - "/child//sponsor", + "/child//sponsor", type="http", auth="public", website=True, sitemap=False, ) - def redirect_old_child_sponsor(self, child, **kw): + def redirect_old_child_sponsor(self, child_identifier, **kw): """ This is a deprecated route of MyCompassion 1.0. From MyCompassion 2.0, we ensured a proper redirection - for user using old links. + for users using old links. """ - # Extract model ID - child_slug = slug(child) - new_url = f"/my2/new-sponsorship/{child_slug}" + + # If the URL provided is a basic integer (e.g., "241011"), + # fetch the record with sudo() and convert it to a proper slug + if child_identifier.isdigit(): + child_record = ( + request.env["compassion.child"].sudo().browse(int(child_identifier)) + ) + if child_record.exists(): + child_identifier = slug(child_record) + + new_url = f"/my2/new-sponsorship/{child_identifier}" # Extract and append any query parameters (like UTMs) query_string = request.httprequest.query_string.decode("utf-8")