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()
예제 #2
0
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.')
예제 #3
0
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}))
예제 #4
0
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",
     })
예제 #7
0
파일: views.py 프로젝트: zack07aman/Fusion
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']))
예제 #8
0
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}))
예제 #9
0
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')
예제 #10
0
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')
예제 #11
0
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)
예제 #12
0
 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)
예제 #13
0
 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)
예제 #14
0
파일: views.py 프로젝트: FusionIIIT/Fusion
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')
예제 #16
0
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')
예제 #17
0
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)