Skip to content

Commit ed1f564

Browse files
authored
Add build detail view beta notification (#11208)
* Add build detail view beta notification This adds a notification to the corresponding beta build detail view, and works for both community and commercial. There are two separate patterns here as the authentication is a little bit different between the two sites. * Fix typo * Update logic to support a link on the new dashboard too
1 parent e4b9e12 commit ed1f564

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

readthedocs/builds/views.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,28 @@ def get_context_data(self, **kwargs):
168168
context["project"] = self.project
169169

170170
build = self.get_object()
171-
context["notifications"] = build.notifications.all()
172171

172+
# Temporary notification to point to the same page on the new dashboard
173+
#
174+
# To support readthedocs.com, we have to point to the login view. We
175+
# can't point directly to the build view on the new dashboard as this
176+
# will give the users a 404 because they aren't logged in.
177+
#
178+
# On community, we _don't want this_ as this requires the user to have
179+
# a login to view the new dashboard.
180+
url_domain = settings.PRODUCTION_DOMAIN
181+
if url_domain.startswith("beta."):
182+
url_domain = url_domain[5:]
183+
else:
184+
url_domain = f"beta.{url_domain}"
185+
url_build = build.get_absolute_url()
186+
# Point to the login view with the build as ?next. We are expecting
187+
# users to have accounts to view this.
188+
if settings.RTD_ALLOW_ORGANIZATIONS:
189+
url_build = reverse("account_login") + f"?next={url_build}"
190+
context["url_switch_dashboard"] = f"https://{url_domain}{url_build}"
191+
192+
context["notifications"] = build.notifications.all()
173193
if not build.notifications.filter(
174194
message_id=BuildAppError.GENERIC_WITH_BUILD_ID
175195
).exists():

readthedocs/templates/builds/build_detail.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@
2828
{% endblock %}
2929

3030
{% block content %}
31+
{% block build_detail_beta %}
32+
{% comment %}
33+
Temporary notification to point to the beta dashboard, url_beta comes from the view
34+
{% endcomment %}
35+
{% if url_switch_dashboard %}
36+
<div class="notifications">
37+
<p class="notification notification-20">
38+
{% blocktrans trimmed with url=url_switch_dashboard %}
39+
Our new beta dashboard is now available for testing!
40+
<a href="{{ url }}">Try viewing this build on the new dashboard</a>.
41+
{% endblocktrans %}
42+
</p>
43+
</div>
44+
{% endif %}
45+
{% endblock build_detail_beta %}
46+
3147
<div class="build build-detail" id="build-detail">
3248

3349
{% if build.state != "finished" and build.state != "cancelled" and request.user|is_admin:project %}

0 commit comments

Comments
 (0)