Source code for notifications.views.redirect

from django.shortcuts import redirect
from django.utils import timezone
from post_office.models import Email

from notifications.models import Snooper






[docs] def email_click_handler(request, message_id, redirect_path): """This is the entry point for email clicks so we know who has clicked on a link in an email. Parameters are message_id (maps to Django Post Office id) and path. The path has ! instead of / """ # TODO: This is not in use yet. We need to change the email sender to use these links and it also # TODO: needs to be extended to allow urls for other sites # TODO: To implement you need to go to AWS SES and change the configuration set to not track clicks # Try to load Django Post Office email with this id email = Email.objects.filter(message_id=message_id).first() if email: # Try to find matching Snooper object snooper = Snooper.objects.filter(post_office_email=email).first() # Update click count if snooper: snooper.ses_clicked_count += 1 snooper.ses_last_clicked_at = timezone.now() snooper.save() return redirect("/" + redirect_path.replace("!", "/"))