示例#1
0
def read_notification(request):
    try:
        queryset = request.user.misago_notifications
        notification = queryset.get(id=request.POST['notification'])

        if notification.is_new:
            is_changed = True
            with atomic():
                notification.is_new = False
                notification.save(update_fields=['is_new'])
                assert_real_new_notifications_count(request.user)
        else:
            is_changed = False

        if request.is_ajax():
            return JsonResponse({'is_error': False, 'is_changed': is_changed})
        else:
            messages.success(request, _("Notification was marked as read."))
            return redirect('misago:notifications')
    except Notification.DoesNotExist:
        message = _("Specified notification could not be found.")
        if request.is_ajax():
            return JsonResponse({
                'is_error': True,
                'message': message,
            })
        else:
            messages.error(request, message)
            return redirect('misago:notifications')
示例#2
0
文件: views.py 项目: hwy801207/Misago
def read_notification(request):
    try:
        queryset = request.user.misago_notifications
        notification = queryset.get(id=request.POST['notification'])

        if notification.is_new:
            is_changed = True
            with atomic():
                notification.is_new = False
                notification.save(update_fields=['is_new'])
                assert_real_new_notifications_count(request.user)
        else:
            is_changed = False

        if request.is_ajax():
            return JsonResponse({
                'is_error': False,
                'is_changed': is_changed
            })
        else:
            messages.success(request, _("Notification was marked as read."))
            return redirect('misago:notifications')
    except Notification.DoesNotExist:
        message = _("Specified notification could not be found.")
        if request.is_ajax():
            return JsonResponse({
                'is_error': True,
                'message': message,
            })
        else:
            messages.error(request, message)
            return redirect('misago:notifications')
示例#3
0
文件: views.py 项目: hwy801207/Misago
def go_to_notification(request, notification_id, trigger):
    queryset = request.user.misago_notifications.select_for_update()
    notification = get_object_or_404(
        queryset, pk=notification_id, trigger=trigger)

    if notification.is_new:
        notification.is_new = False
        notification.save(update_fields=['is_new'])
        assert_real_new_notifications_count(request.user)

    return redirect(notification.url)
示例#4
0
def go_to_notification(request, notification_id, hash):
    queryset = request.user.misago_notifications.select_for_update()
    notification = get_object_or_404(
        queryset, pk=notification_id, hash=hash)

    if notification.is_new:
        update_qs = request.user.misago_notifications.filter(hash=hash)
        update_qs.update(is_new=False)
        assert_real_new_notifications_count(request.user)

    return redirect(notification.url)
示例#5
0
def go_to_notification(request, notification_id, trigger):
    queryset = request.user.misago_notifications.select_for_update()
    notification = get_object_or_404(queryset,
                                     pk=notification_id,
                                     trigger=trigger)

    if notification.is_new:
        notification.is_new = False
        notification.save(update_fields=['is_new'])
        assert_real_new_notifications_count(request.user)

    return redirect(notification.url)
示例#6
0
文件: views.py 项目: sun5495/Misago
def notifications(request):
    if request.method == 'POST':
        read_all(request)
        if not request.is_ajax():
            return redirect('misago:notifications')
    else:
        assert_real_new_notifications_count(request.user)

    if request.is_ajax():
        return dropdown(request)
    else:
        return full_page(request)
示例#7
0
def notifications(request):
    if request.method == 'POST':
        if 'read-all' in request.POST:
            return read_all(request)
        if request.POST.get('notification'):
            return read_notification(request)
    else:
        assert_real_new_notifications_count(request.user)

    if request.is_ajax():
        return dropdown(request)
    else:
        return full_page(request)
示例#8
0
文件: views.py 项目: hwy801207/Misago
def notifications(request):
    if request.method == 'POST':
        if 'read-all' in request.POST:
            return read_all(request)
        if request.POST.get('notification'):
            return read_notification(request)
    else:
        assert_real_new_notifications_count(request.user)

    if request.is_ajax():
        return dropdown(request)
    else:
        return full_page(request)