feat: Link to comment
This commit is contained in:
parent
b9c2de751d
commit
0b08647c7e
@ -559,6 +559,11 @@ class BaseNotification(models.Model):
|
|||||||
class CommentNotification(BaseNotification):
|
class CommentNotification(BaseNotification):
|
||||||
comment = models.ForeignKey(Comment, on_delete=models.CASCADE, verbose_name=_('Antwort'))
|
comment = models.ForeignKey(Comment, on_delete=models.CASCADE, verbose_name=_('Antwort'))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url(self):
|
||||||
|
print(f"URL: self.comment.get_absolute_url()")
|
||||||
|
return self.comment.get_absolute_url
|
||||||
|
|
||||||
|
|
||||||
class Subscriptions(models.Model):
|
class Subscriptions(models.Model):
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('Nutzer*in'))
|
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('Nutzer*in'))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{% load custom_tags %}
|
{% load custom_tags %}
|
||||||
<div class="notification">
|
<div class="notification">
|
||||||
<div class="notification-header">
|
<div class="notification-header">
|
||||||
<b>{{ notification.title }}</b>
|
<a href="{{ notification.url }}" ><b>{{ notification.title }}</b></a>
|
||||||
{{ notification.created_at }}
|
{{ notification.created_at }}
|
||||||
<form class="notification-card-mark-read" method="POST">
|
<form class="notification-card-mark-read" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
@ -322,11 +322,11 @@ def user_detail(request, user_id):
|
|||||||
if action == "notification_mark_read":
|
if action == "notification_mark_read":
|
||||||
notification_id = request.POST.get("notification_id")
|
notification_id = request.POST.get("notification_id")
|
||||||
print(notification_id)
|
print(notification_id)
|
||||||
notification = BaseNotification.objects.get(pk=notification_id)
|
notification = CommentNotification.objects.get(pk=notification_id)
|
||||||
notification.read = True
|
notification.read = True
|
||||||
notification.save()
|
notification.save()
|
||||||
elif action == "notification_mark_all_read":
|
elif action == "notification_mark_all_read":
|
||||||
notifications = BaseNotification.objects.filter(user=request.user, mark_read=False)
|
notifications = CommentNotification.objects.filter(user=request.user, mark_read=False)
|
||||||
for notification in notifications:
|
for notification in notifications:
|
||||||
notification.read = True
|
notification.read = True
|
||||||
notification.save()
|
notification.save()
|
||||||
@ -334,7 +334,7 @@ def user_detail(request, user_id):
|
|||||||
user = User.objects.get(id=user_id)
|
user = User.objects.get(id=user_id)
|
||||||
context = {"user": user,
|
context = {"user": user,
|
||||||
"adoption_notices": AdoptionNotice.objects.filter(created_by=user),
|
"adoption_notices": AdoptionNotice.objects.filter(created_by=user),
|
||||||
"notifications": BaseNotification.objects.filter(user=user, read=False)}
|
"notifications": CommentNotification.objects.filter(user=user, read=False)}
|
||||||
return render(request, 'fellchensammlung/details/detail-user.html', context=context)
|
return render(request, 'fellchensammlung/details/detail-user.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user