Skip to content

Commit

Permalink
use absolute filter
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Aug 10, 2023
1 parent 747638f commit 54f38dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 2 additions & 5 deletions ephios_testplugin/notification.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from urllib.parse import urljoin

from django.conf import settings
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from ephios.core.models import Notification
from ephios.core.services.notifications.types import AbstractNotificationHandler
from ephios.core.templatetags.settings_extras import make_absolute


class TestNotification(AbstractNotificationHandler):
Expand Down Expand Up @@ -32,8 +30,7 @@ def get_actions(cls, notification):
return [
(
_("Look at test notification"),
urljoin(
settings.GET_SITE_URL(), reverse("testplugin:test_notifications")
make_absolute( reverse("testplugin:test_notifications")
),
)
]
8 changes: 5 additions & 3 deletions ephios_testplugin/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import io
import logging
from email import generator as email_generator
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from urllib.parse import urljoin

from django import forms
from django.conf import settings
Expand All @@ -21,10 +21,12 @@
installed_notification_types,
notification_type_from_slug,
)
from ephios.core.templatetags.settings_extras import make_absolute
from ephios.extra.mixins import StaffRequiredMixin

from ephios_testplugin.notification import TestNotification

logger = logging.getLogger(__name__)

class TestIndexView(StaffRequiredMixin, TemplateView):
template_name = "testplugin/test_index.html"
Expand Down Expand Up @@ -71,8 +73,7 @@ def rendered_email_context(self, notification_type):
"token": default_token_generator.make_token(self.request.user),
"event_id": Event.objects.first().id,
"participation_id": LocalParticipation.objects.first().id,
"disposition_url": urljoin(
settings.GET_SITE_URL(),
"disposition_url": make_absolute(
reverse(
"core:shift_disposition",
kwargs={"pk": LocalParticipation.objects.first().shift.pk},
Expand Down Expand Up @@ -116,6 +117,7 @@ def rendered_email_context(self, notification_type):
plaintext=notification_type.as_plaintext(notification),
)
except Exception as e:
logger.exception("Error rendering email template")
return {
"email": f"Error: {e}",
}
Expand Down

0 comments on commit 54f38dd

Please sign in to comment.