Skip to content

Commit 695667e

Browse files
humitosagjohnson
andauthored
New dashboard: notification to point users there (#11161)
* New dashboard: notification to point users there We can add the notifications to all the users by running the following code: ```python from readthedocs.core.notifications import MESSAGE_BETA_DASHBOARD_AVAILABLE for user in User.objects.all(): Notification.objects.add( message_id=MESSAGE_BETA_DASHBOARD_AVAILABLE, attached_to=user, dismissable=True, ) ``` This will show a one-time dismissable notification to these users. In the future (weeks, months) if we can show them another notification like this one as a reminder, we can run the same code again. Related readthedocs/ext-theme#183 * Update readthedocs/core/notifications.py Co-authored-by: Anthony <[email protected]> * Change the content of the notification based on old/new dashboard * Test fixed * Update readthedocs/core/notifications.py Co-authored-by: Anthony <[email protected]> --------- Co-authored-by: Anthony <[email protected]>
1 parent 03c03fa commit 695667e

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

readthedocs/core/context_processors.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def readthedocs_processor(request):
2525
"USE_ORGANIZATIONS": settings.RTD_ALLOW_ORGANIZATIONS,
2626
"SUPPORT_EMAIL": settings.SUPPORT_EMAIL,
2727
"PUBLIC_API_URL": settings.PUBLIC_API_URL,
28+
"RTD_EXT_THEME_ENABLED": settings.RTD_EXT_THEME_ENABLED,
2829
}
2930
return exports
3031

readthedocs/core/notifications.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
from django.utils.translation import gettext_lazy as _
66

7-
from readthedocs.notifications.constants import WARNING
7+
from readthedocs.notifications.constants import INFO, WARNING
88
from readthedocs.notifications.messages import Message, registry
99

1010
MESSAGE_EMAIL_VALIDATION_PENDING = "core:email:validation-pending"
11+
MESSAGE_BETA_DASHBOARD_AVAILABLE = "core:dashboard:beta-available"
1112
messages = [
1213
Message(
1314
id=MESSAGE_EMAIL_VALIDATION_PENDING,
@@ -22,6 +23,25 @@
2223
),
2324
type=WARNING,
2425
),
26+
Message(
27+
id=MESSAGE_BETA_DASHBOARD_AVAILABLE,
28+
header=_("New beta dashboard"),
29+
body=_(
30+
textwrap.dedent(
31+
"""
32+
{% if RTD_EXT_THEME_ENABLED %}
33+
This dashboard is currently in beta,
34+
you can <a href="https://{{ PRODUCTION_DOMAIN }}">return to the legacy dashboard</a> if you encounter any problems.
35+
Feel free to <a href="https://{{ PRODUCTION_DOMAIN }}/support/">report any feedback</a> you may have.
36+
{% else %}
37+
Our new <strong>beta dashboard</strong> is now available for testing.
38+
<a href="https://beta.{{ PRODUCTION_DOMAIN }}/">Give it a try</a> and send us feedback.
39+
{% endif %}
40+
"""
41+
).strip(),
42+
),
43+
type=INFO,
44+
),
2545
]
2646

2747

readthedocs/core/static-src/core/js/site.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Dismiss a notification
44
module.exports.handle_notification_dismiss = function () {
55
$(document).ready(function () {
6-
$('ul.notifications li.notification > a').click(function (ev) {
6+
$('ul.notifications li.notification > a.notification-action').click(function (ev) {
77
var url = $(this).attr('href');
88
var dismiss_url = $(this).parent().attr('data-dismiss-url');
99
var csrf_token = $(this).parent().attr('data-csrf-token');

readthedocs/core/static/core/js/site.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readthedocs/rtd_tests/tests/test_notifications.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class TestNotification(EmailNotification):
5555
"PRODUCTION_DOMAIN": "readthedocs.org",
5656
"PUBLIC_DOMAIN": mock.ANY,
5757
"PUBLIC_API_URL": mock.ANY,
58+
"RTD_EXT_THEME_ENABLED": mock.ANY,
5859
"SITE_ROOT": mock.ANY,
5960
"SUPPORT_EMAIL": "[email protected]",
6061
"TEMPLATE_ROOT": mock.ANY,

0 commit comments

Comments
 (0)