Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass along UTMs when doing a blog redirect #13381

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions webapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,17 @@ def dispatch_request(self, slug):
if "article" not in context:
return flask.abort(404)

# Redirect canonical annoucements
# Capture the original query string
original_query_string = flask.request.query_string.decode("utf-8")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this variable is used only inside the if block below, can you declare it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akbarkz done, good catch, thank you


# Redirect canonical announcements
group = context["article"].get("group")
if isinstance(group, dict) and group["id"] == 2100:
return flask.redirect(f"https://canonical.com/blog/{slug}")
redirect_url = f"https://canonical.com/blog/{slug}"
# Append the original query string to the redirect URL
if original_query_string:
redirect_url += f"?{original_query_string}"
return flask.redirect(redirect_url)

# Set blog notice date
blog_notice = {}
Expand Down
Loading