Skip to content

Commit

Permalink
Notifications: fix rendering (#11133)
Browse files Browse the repository at this point in the history
* Notifications: fix rendering

In #11094 we introduce a bug in the rendering because we stopped initializing
the Message class with the `format_values` from the `Notification` object
itself. That's why all the notifications weren't rendering these values.

* Notifications: typo
  • Loading branch information
humitos committed Feb 21, 2024
1 parent 06140a3 commit e7849c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion readthedocs/config/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
Config validation error in <code>{{key}}</code>.
Expected one of ({{choices}}), got type <code>{{value|to_class_name}}</code> (<code>{{value}}</code>).
Double check the type of the value.
A string may be required (e.g. <code>"3.10"</code> insted of <code>3.10</code>)
A string may be required (e.g. <code>"3.10"</code> instead of <code>3.10</code>)
"""
).strip(),
),
Expand Down
10 changes: 6 additions & 4 deletions readthedocs/notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from django.utils.translation import gettext_noop as _
from django_extensions.db.models import TimeStampedModel


from .constants import CANCELLED, DISMISSED, READ, UNREAD, WARNING
from .messages import Message, registry
from .querysets import NotificationQuerySet
Expand Down Expand Up @@ -67,9 +66,12 @@ def __str__(self):

def get_message(self):
# Pass the instance attached to this notification
format_values = {
"instance": self.attached_to,
}
format_values = self.format_values or {}
format_values.update(
{
"instance": self.attached_to,
}
)

message = registry.get(self.message_id, format_values=format_values)
if message is None:
Expand Down

0 comments on commit e7849c7

Please sign in to comment.