Beispiel #1
0
def block_user(request, profile):
    request.user.lock()

    if request.user.is_blocking(profile):
        request.user.blocks.remove(profile)
        blocked = False
    else:
        allow_block_user(request.user, profile)
        blocked = True
        request.user.blocks.add(profile)

    if blocked:
        message = _("You are now blocking %(user)s.")
    else:
        message = _("You have stopped blocking %(user)s.")
    message = message % {'user': profile.username}

    if request.is_ajax:
        return {'is_blocking': blocked, 'message': message}
    else:
        messages.success(request, message)
Beispiel #2
0
def block_user(request, profile):
    request.user.lock()

    if request.user.is_blocking(profile):
        request.user.blocks.remove(profile)
        blocked = False
    else:
        allow_block_user(request.user, profile)
        blocked = True
        request.user.blocks.add(profile)

    if blocked:
        message = _("You are now blocking %(user)s.")
    else:
        message = _("You have stopped blocking %(user)s.")
    message = message % {'user': profile.username}

    if request.is_ajax:
        return {'is_blocking': blocked, 'message': message}
    else:
        messages.success(request, message)