fix: use ownerfor subscriptions

This commit is contained in:
moanos [he/him] 2024-09-29 17:18:47 +02:00
parent 51df946bac
commit 2d20423736

View File

@ -88,14 +88,14 @@ def adoption_notice_detail(request, adoption_notice_id):
# Auto-subscribe user to adoption notice # Auto-subscribe user to adoption notice
subscription, created = Subscriptions.objects.get_or_create(adoption_notice=adoption_notice, subscription, created = Subscriptions.objects.get_or_create(adoption_notice=adoption_notice,
user=request.user) owner=request.user)
subscription.save() subscription.save()
# Notify users that a comment was added # Notify users that a comment was added
for subscription in adoption_notice.get_subscriptions(): for subscription in adoption_notice.get_subscriptions():
# Create a notification but only if the user is not the one that posted the comment # Create a notification but only if the user is not the one that posted the comment
if subscription.user != request.user: if subscription.owner != request.user:
notification = CommentNotification(user=subscription.user, notification = CommentNotification(user=subscription.owner,
title=f"{adoption_notice.name} - Neuer Kommentar", title=f"{adoption_notice.name} - Neuer Kommentar",
text=f"{request.user}: {comment_instance.text}", text=f"{request.user}: {comment_instance.text}",
comment=comment_instance) comment=comment_instance)