def _dissolve_connection_between_users(username): logged_user, to_user = _get_requesting_user_and_logged_in_user_obj( "" or username.lower()) if to_user and _is_there_relationship_between_users(logged_user, to_user): Relationship.delete_connection_between_users(logged_user, to_user)
def unblock(username): logged_user, to_user = _get_requesting_user_and_logged_in_user_obj( username) if to_user: rel = Relationship.get_relationship(logged_user, to_user) if rel == constants.BLOCKED: Relationship.delete_connection_between_users(logged_user, to_user) return _redirect_to_referred_url_if_safe(username) abort(404)
def block(username): logged_user, to_user = _get_requesting_user_and_logged_in_user_obj( username) if to_user and logged_user: Relationship.delete_connection_between_users(to_user, logged_user) Relationship(from_user=logged_user, to_user=to_user, relationship_type=Relationship.BLOCKED, status=Relationship.APPROVED).save() return _redirect_to_referred_url_if_safe(username) abort(404)