Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions my_compassion/controllers/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -335,6 +338,38 @@ 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/<string:child_identifier>/sponsor",
type="http",
auth="public",
website=True,
sitemap=False,
)
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 users using old links.
"""

# 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")
if query_string:
new_url = f"{new_url}?{query_string}"

return request.redirect(new_url, code=301)

@route("/my/download/<source>", type="http", auth="user", website=True)
def download_file(self, source, **kw):
"""
Expand Down
Loading