@@ -38,35 +38,45 @@ def get(self, request, *_, **__):
38
38
39
39
class HomepageView (TemplateView ):
40
40
"""
41
- Conditionally show the home page or redirect to the login page .
41
+ Conditionally redirect to website home page or to dashboard .
42
42
43
- On the current dashboard, this shows the application homepage. However, we
44
- no longer require this page in our application as we have a similar page on
45
- our website. Instead, redirect to our login page on the new dashboard.
43
+
44
+ User hitting readthedocs.org / readthedocs.com
45
+ 1. when user is logged in, redirect to dashboard
46
+ 2. when user is logged off, redirect to https://about.readthedocs.com/
47
+
48
+ User hitting app.readthedocs.org / app.readthedocs.com
49
+ 1. when user is logged in, redirect to dashboard
50
+ 2. when user is logged off, redirect to login page
46
51
"""
47
52
48
53
template_name = "homepage.html"
49
54
50
55
def get (self , request , * args , ** kwargs ):
51
- # Redirect to login page
52
- return redirect (reverse ("account_login" ))
53
-
56
+ # Request hitting the old domain (readthedocs.org / readthedocs.com)
57
+ if request .get_host () == settings .PRODUCTION_DOMAIN .replace ("app." , "" ):
58
+ # Redirect to user dashboard for logged in users
59
+ if request .user .is_authenticated :
60
+ return redirect ("projects_dashboard" )
61
+
62
+ # Redirect to ``about.`` in production
63
+ if not settings .DEBUG :
64
+ query_string = f"?ref={ settings .PRODUCTION_DOMAIN } "
65
+ if request .META ["QUERY_STRING" ]:
66
+ # Small hack to not append `&` to URLs without a query_string
67
+ query_string += "&" + request .META ["QUERY_STRING" ]
68
+
69
+ # Do a 302 here so that it varies on logged in status
70
+ return redirect (f"https://about.readthedocs.com/{ query_string } " , permanent = False )
71
+
72
+ # Request hitting app.readthedocs.org / app.readthedocs.com
73
+ #
54
74
# Redirect to user dashboard for logged in users
55
75
if request .user .is_authenticated :
56
76
return redirect ("projects_dashboard" )
57
77
58
- # Redirect to ``about.`` in production
59
- if not settings .DEBUG :
60
- query_string = f"?ref={ settings .PRODUCTION_DOMAIN } "
61
- if request .META ["QUERY_STRING" ]:
62
- # Small hack to not append `&` to URLs without a query_string
63
- query_string += "&" + request .META ["QUERY_STRING" ]
64
-
65
- # Do a 302 here so that it varies on logged in status
66
- return redirect (f"https://about.readthedocs.com{ query_string } " , permanent = False )
67
-
68
- # Show the homepage for local dev
69
- return super ().get (request , * args , ** kwargs )
78
+ # Redirect to login page
79
+ return redirect (reverse ("account_login" ))
70
80
71
81
72
82
class SupportView (PrivateViewMixin , TemplateView ):
0 commit comments