示例#1
0
def addNotification(request, secondUser, postID, notificationState, isAdd):
    post = None

    try:
        post = get_object_or_404(Post, id=postID)
    except:
        pass

    currUser = get_object_or_404(MyUser, user=request.user)
    tmpUser = secondUser

    notification = Notification()
    notification.firstUser = currUser
    notification.secondUser = tmpUser
    notification.post = post
    notification.notificationState = notificationState
    notification.save()

    if isAdd:
        currUser.first.add(notification)
        tmpUser.second.add(notification)

    else:
        Notification.objects.filter(firstUser=notification.firstUser).filter(secondUser=notification.secondUser) \
                                        .filter(post=notification.post) \
                                        .filter(notificationState=notification.notificationState).delete()
示例#2
0
def addNotification(request, secondUser, postID, notificationState, isAdd):
    post = None

    try:
        post = get_object_or_404(Post, id=postID)
    except:
        pass

    currUser = get_object_or_404(MyUser, user=request.user)
    tmpUser = secondUser

    notification = Notification()
    notification.firstUser = currUser
    notification.secondUser = tmpUser
    notification.post = post
    notification.notificationState = notificationState

    if isAdd:
        currUser.first.add(notification)
        tmpUser.second.add(notification)

    else:
        Notification.objects.filter(firstUser=notification.firstUser).filter(secondUser=notification.secondUser) \
                                        .filter(post=notification.post) \
                                        .filter(notificationState=notification.notificationState).delete()