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())})
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())})
def get_num(user): if not user.is_authenticated(): return 0 return len(BaseNotification.by_receiver(user, read=False, deleted=False))
def get_notifications(user): if not user.is_authenticated(): return [] return BaseNotification.by_receiver(user, deleted=False).order_by('-date')