Skip to content

Add redirect to about.readthedocs.com for logged out users #10570

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

Merged
merged 3 commits into from
Aug 1, 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
17 changes: 17 additions & 0 deletions readthedocs/core/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,25 @@ class HomepageView(TemplateView):
template_name = 'homepage.html'

def get(self, request, *args, **kwargs):
# Redirect to login page for new dashboard
if settings.RTD_EXT_THEME_ENABLED:
return redirect(reverse("account_login"))

# Redirect to user dashboard for logged in users
if request.user.is_authenticated:
return redirect("projects_dashboard")

# Redirect to ``about.`` in production
if not settings.DEBUG:
query_string = "?ref=dotorg-homepage"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing we don't use this view on the commercial application, as we are already adding this to the requests on commercial. But if we do, this query string could be conditional based on the application instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, we're overriding it. Could probably stop now though, if we wanted 🤔

if request.META["QUERY_STRING"]:
# Small hack to not append `&` to URLs without a query_string
query_string += "&" + request.META["QUERY_STRING"]
return redirect(
f"https://about.readthedocs.com{query_string}", permanent=False
)

# Show the homepage for local dev
return super().get(request, *args, **kwargs)

def get_context_data(self, **kwargs):
Expand Down