Exemplo n.º 1
0
def notification_mark(id, mark):
    notification = BaseNotification.objects(id=id).first()
    if notification is None:
        abort(404)
    if not notification.receiver.user == current_user._get_current_object():
        abort(404)

    if mark == 'read':
        notification.read = True
    elif mark == 'unread':
        notification.read = False
    else:
        abort(404)

    notification.save()

    return json.dumps({'notification_count': get_num(current_user._get_current_object())})
Exemplo n.º 2
0
def notification_mark(id, mark):
    notification = BaseNotification.objects(id=id).first()
    if notification is None:
        abort(404)
    if not notification.receiver.user == current_user._get_current_object():
        abort(404)

    if mark == 'read':
        notification.read = True
    elif mark == 'unread':
        notification.read = False
    else:
        abort(404)

    notification.save()

    return json.dumps(
        {'notification_count': get_num(current_user._get_current_object())})
Exemplo n.º 3
0
def get_num(user):
    if not user.is_authenticated():
        return 0
    return len(BaseNotification.by_receiver(user, read=False, deleted=False))
Exemplo n.º 4
0
def get_notifications(user):
    if not user.is_authenticated():
        return []
    return BaseNotification.by_receiver(user, deleted=False).order_by('-date')
Exemplo n.º 5
0
def get_num(user):
    if not user.is_authenticated():
        return 0
    return len(BaseNotification.by_receiver(user, read=False, deleted=False))
Exemplo n.º 6
0
def get_notifications(user):
    if not user.is_authenticated():
        return []
    return BaseNotification.by_receiver(user, deleted=False).order_by('-date')