Skip to content

Commit 658f825

Browse files
stsewdhumitos
andauthored
Contact users: make notification sticky (#8516)
Co-authored-by: Manuel Kaufmann <[email protected]>
1 parent effebd6 commit 658f825

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

media/css/core.css

+1
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ p.build-missing { font-size: .8em; color: #9d9a55; margin: 0 0 3px; }
620620
}
621621
.notification-20,
622622
.notification-25,
623+
.notification-26,
623624
.notification-101,
624625
.notification-102 {
625626
color: #5a5;

readthedocs/core/management/commands/contact_owners.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Command(BaseCommand):
2929
3030
django-admin contact_owners --email email.md
3131
32-
Email and send a sticky notification to all owners of the "readthedocs" organization::
32+
Email and send an ephemeral (disappears after shown once) notification to all owners of the "readthedocs" organization::
3333
3434
django-admin contact_owners --email email.md --notification notification.md --organization readthedocs # noqa
3535
@@ -74,6 +74,16 @@ def add_arguments(self, parser):
7474
'--notification',
7575
help='Path to a file with the notification content in markdown.',
7676
)
77+
parser.add_argument(
78+
'--sticky',
79+
action='store_true',
80+
dest='sticky',
81+
default=False,
82+
help=(
83+
'Make the notification sticky '
84+
'(the notification stays until the user closes it)'
85+
)
86+
)
7787
parser.add_argument(
7888
'--organization',
7989
help='Organization slug to filter by.',
@@ -146,6 +156,7 @@ def handle(self, *args, **options):
146156
email_subject=email_subject,
147157
email_content=email_content,
148158
notification_content=notification_content,
159+
sticky_notification=options['sticky'],
149160
dryrun=not options['production'],
150161
)
151162

readthedocs/core/utils/contact.py

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.conf import settings
66
from django.core.mail import send_mail
77
from django.template import Context, Engine
8+
from messages_extends import constants as message_constants
89

910
from readthedocs.notifications import SiteNotification
1011
from readthedocs.notifications.backends import SiteBackend
@@ -18,6 +19,7 @@ def contact_users(
1819
email_content=None,
1920
from_email=None,
2021
notification_content=None,
22+
sticky_notification=False,
2123
context_function=None,
2224
dryrun=True,
2325
):
@@ -61,6 +63,9 @@ def contact_users(
6163

6264
class TempNotification(SiteNotification):
6365

66+
if sticky_notification:
67+
success_level = message_constants.SUCCESS_PERSISTENT
68+
6469
def render(self, *args, **kwargs):
6570
context = {
6671
'user': self.user,

0 commit comments

Comments
 (0)