Commit 6bce966a authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[search][signals] Fix implementation and add link generation

parent cf34bf00
......@@ -39,9 +39,16 @@ from .models import Leaderboard
@receiver(models.signals.pre_delete, sender=Leaderboard)
def notify_users(sender, instance, **kwargs):
"""Notify users the leaderboard was deleted"""
emails = instance.notify.exclude(instance.author).values_list("email", flat=True)
emails = instance.notify.exclude(
username=instance.search.author.username
).values_list("email", flat=True)
if emails:
current_site = Site.objects.get_current()
leaderboard_search_link = (
f"https://{current_site.domain}" + instance.search.get_absolute_url()
)
template_path = "search/leaderboard_deleted.txt"
subject = 'Leaderboard "%s" was deleted' % instance.search.fullname()
mesg = EmailMessage(
......@@ -51,7 +58,7 @@ def notify_users(sender, instance, **kwargs):
{
"leaderboard": instance,
"beat_version": version.__version__,
"site": current_site,
"leaderboard_search_link": leaderboard_search_link,
},
),
settings.DEFAULT_FROM_EMAIL,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment