def mark_as_unread(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404(Notification, recipient=request.user, id=notification_id) notification.mark_as_unread()
def delete_notification(request, slug): notif_id = slug2id(slug) notif = get_object_or_404(Notification, recipient=request.user, id=notif_id) notif.delete() return HttpResponse('Bildirim Silindi.')
def mark_as_read_and_redirect(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404( Notification, recipient=request.user, id=notification_id) notification.mark_as_read() complaint_id=notification.verb return HttpResponseRedirect(reverse(notification.data['url'],kwargs={'detailcomp_id1':complaint_id}))
def mark_notification_as_read(request, slug): notification_id = slug2id(slug) notification = Notification.objects.get(recipient=request.user, id=notification_id) notification.mark_as_read() return HttpResponse(status=200)
def mark_as_read(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404(Notification, recipient=request.user, id=notification_id) notification.mark_as_read() return Response({"result": "success"})
def retrieve(self, request, pk=None): notification_id = slug2id(pk) notification = get_object_or_404(Notification, recipient=request.user, id=notification_id) notification.mark_as_unread() return Response({ "results": "success", })
def mark_as_read_and_redirect(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404(Notification, recipient=request.user, id=notification_id) notification.mark_as_read() return HttpResponseRedirect(reverse(notification.data['url']))
def mark_as_read_and_redirect(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404( Notification, recipient=request.user, id=notification_id) notification.mark_as_read() _next = request.GET.get('next') pk=notification.target_object_id if _next: return redirect(_next) return HttpResponseRedirect(reverse(notification.data['target_url'],kwargs={'pk':pk}))
def mark_as_unread(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404( Notification, recipient=request.user, id=notification_id) notification.mark_as_unread() _next = request.GET.get('next') if _next: return redirect(_next) return redirect('notifications:unread')
def mark_all_as_read(request): if 'notif_slugs_to_mark_as_read' not in request.POST: return HttpResponse(status=403) slugs_string = request.POST['notif_slugs_to_mark_as_read'] splitted = slugs_string.split(',') trimmed = list(map(lambda ele: ele.strip(), splitted)) casted = list(map(_safe_cast, trimmed)) filtered = list(filter(lambda ele: ele is not None, casted)) ids = list(map(lambda ele: slug2id(ele), filtered)) for notification_id in ids: notification = Notification.objects.get(recipient=request.user, id=notification_id) notification.mark_as_read() return HttpResponse(status=200)
def post(self, request, notification_slug): user = User.objects.get(email=request.user) notification_id = slug2id(notification_slug) notification = Notification.objects.filter(recipient__pk=user.id, pk=notification_id) deleted_row, deleted_row_dict = notification.delete() if bool(int(deleted_row)): return Response({ "detail": "Notification was deleted.", }) else: return Response({ "detail": "Could not delete that notofication.", }, status=status.HTTP_400_BAD_REQUEST)
def post(self, request, notification_slug): user = User.objects.get(email=request.user) notification_id = slug2id(notification_slug) notifications = Notification.objects.filter(recipient__pk=user.id, pk=notification_id) marked = bool(int(notifications.mark_all_as_unread())) if marked: return Response({ "detail": "Notification marked as unread.", }) else: return Response({ "detail": "Could not mark as unread.", }, status=status.HTTP_400_BAD_REQUEST)
def mark_as_read_and_redirect(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404(Notification, recipient=request.user, id=notification_id) notification.mark_as_read() # This conditional statement is True only in # case of complaint_module. if (notification.data['module'] == 'Complaint System'): complaint_id = notification.description return HttpResponseRedirect( reverse(notification.data['url'], kwargs={'detailcomp_id1': complaint_id})) else: return HttpResponseRedirect(reverse(notification.data['url']))
def delete(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404( Notification, recipient=request.user, id=notification_id) if settings.get_config()['SOFT_DELETE']: notification.deleted = True notification.save() else: notification.delete() _next = request.GET.get('next') if _next: return redirect(_next) return redirect('notifications:all')
def mark_as_unread(request, slug=None): notification_id = slug2id(slug) notification = get_object_or_404( Notification, recipient=request.user, id=notification_id) notification.mark_as_unread() _next = request.GET.get('next') if _next: return redirect(_next) html = "Success" output_data = { 'html': html } return JsonResponse(output_data)