feat: Allow marking notifications as read
This commit is contained in:
		@@ -4,7 +4,12 @@
 | 
				
			|||||||
    <div class="notification-header">
 | 
					    <div class="notification-header">
 | 
				
			||||||
        <b>{{ notification.title }}</b>
 | 
					        <b>{{ notification.title }}</b>
 | 
				
			||||||
        {{ notification.created_at }}
 | 
					        {{ notification.created_at }}
 | 
				
			||||||
        <a class="adoption-card-report-link" href=""><i class="fa-solid fa-check"></i></a>
 | 
					        <form method="POST">
 | 
				
			||||||
 | 
					            {% csrf_token %}
 | 
				
			||||||
 | 
					            <input type="hidden" name="action" value="notification_mark_read">
 | 
				
			||||||
 | 
					            <input type="hidden" name="notification_id" value="{{ notification.pk }}">
 | 
				
			||||||
 | 
					            <button type="submit" id="submit"><i class="fa-solid fa-check"></i></button>
 | 
				
			||||||
 | 
					        </form>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <p>
 | 
					    <p>
 | 
				
			||||||
        {{ notification.text | render_markdown }}
 | 
					        {{ notification.text | render_markdown }}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -315,6 +315,20 @@ def report_detail_success(request, report_id):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def user_detail(request, user_id):
 | 
					def user_detail(request, user_id):
 | 
				
			||||||
 | 
					    if request.method == "POST":
 | 
				
			||||||
 | 
					        action = request.POST.get("action")
 | 
				
			||||||
 | 
					        if action == "notification_mark_read":
 | 
				
			||||||
 | 
					            notification_id = request.POST.get("notification_id")
 | 
				
			||||||
 | 
					            print(notification_id)
 | 
				
			||||||
 | 
					            notification = BaseNotification.objects.get(pk=notification_id)
 | 
				
			||||||
 | 
					            notification.read = True
 | 
				
			||||||
 | 
					            notification.save()
 | 
				
			||||||
 | 
					        elif action == "notification_mark_all_read":
 | 
				
			||||||
 | 
					            notifications = BaseNotification.objects.filter(user=request.user, mark_read=False)
 | 
				
			||||||
 | 
					            for notification in notifications:
 | 
				
			||||||
 | 
					                notification.read = True
 | 
				
			||||||
 | 
					                notification.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user