Skip to content

Commit

Permalink
Notifications: render the URL for account using Django template tag (#…
Browse files Browse the repository at this point in the history
…11521)

* Notifications: render the URL using Django `url` template tag

There is no need to pass this value as a `format_value` since we already have
the organization and we can generate the URL using regular Django template tags.

* Update tests

* Notifications: render the URL for account using Django template tag

Similar to #11465
  • Loading branch information
humitos authored Aug 8, 2024
1 parent 68e1081 commit c2f1819
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion readthedocs/api/v3/tests/responses/notifications-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dismissable": false,
"id": 4,
"message": {
"body": "Your primary email address is not verified.\nPlease <a href=\"\">verify it here</a>.",
"body": "Your primary email address is not verified.\nPlease <a href=\"/accounts/email/\">verify it here</a>.",
"header": "Email address not verified",
"icon_classes": "fas fa-circle-exclamation",
"id": "core:email:validation-pending",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dismissable": false,
"id": 4,
"message": {
"body": "Your primary email address is not verified.\nPlease <a href=\"\">verify it here</a>.",
"body": "Your primary email address is not verified.\nPlease <a href=\"/accounts/email/\">verify it here</a>.",
"header": "Email address not verified",
"icon_classes": "fas fa-circle-exclamation",
"id": "core:email:validation-pending",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dismissable": false,
"id": 4,
"message": {
"body": "Your primary email address is not verified.\nPlease <a href=\"\">verify it here</a>.",
"body": "Your primary email address is not verified.\nPlease <a href=\"/accounts/email/\">verify it here</a>.",
"header": "Email address not verified",
"icon_classes": "fas fa-circle-exclamation",
"id": "core:email:validation-pending",
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
textwrap.dedent(
"""
Your primary email address is not verified.
Please <a href="{{account_email_url}}">verify it here</a>.
Please <a href="{% url 'account_email' %}">verify it here</a>.
"""
).strip(),
),
Expand Down
4 changes: 0 additions & 4 deletions readthedocs/notifications/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from allauth.account.models import EmailAddress
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.urls import reverse

from readthedocs.core.notifications import MESSAGE_EMAIL_VALIDATION_PENDING
from readthedocs.notifications.models import Notification
Expand Down Expand Up @@ -62,7 +61,4 @@ def user_email_verified(instance, *args, **kwargs):
attached_to=instance.user,
message_id=MESSAGE_EMAIL_VALIDATION_PENDING,
dismissable=True,
format_values={
"account_email_url": reverse("account_email"),
},
)
3 changes: 0 additions & 3 deletions readthedocs/projects/views/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ def validate_primary_email(self, user):
attached_to=user,
message_id=MESSAGE_EMAIL_VALIDATION_PENDING,
dismissable=True,
format_values={
"account_email_url": reverse("account_email"),
},
)

def get_queryset(self):
Expand Down

0 comments on commit c2f1819

Please sign in to comment.