def modify_comment(user_id, object_type, object_id):
    object_type = object_type.upper()
    if object_type not in OBJECT_TYPES:
        status_code = 404
        data = {
            'status': 'failed',
            'message': 'Modifying comment failed, unsupported object type',
            'resource_id': object_id
        }
        return make_response(jsonify(data), status_code)
    payload = request.get_json()
    comment = Comment.deserialize(payload)
    comment.object_id = object_id
    comment.object_type = object_type
    comment.user_id = user_id
    status_code, comment_id = update_comment(comment)
    data = {
        'status': 'success',
        'message': 'Created new comment',
        'resource_id': comment_id
    }
    LOG.debug(comment)
    activity = Activity(user_id, "MODIFY_COMMENT", payload)
    add_activity(activity)
    return make_response(jsonify(data), status_code)
def create_card(user_id):
    payload = request.get_json()
    card = Card.deserialize(payload)
    status_code, card_id = add_card(card)
    data = {'status': 'success', 'message': 'Created new card', 'resource_id': card_id}
    LOG.debug(card)
    activity = Activity(user_id, "CREATE_CARD", payload)
    add_activity(activity)
    return make_response(jsonify(data), status_code)
def modify_card(user_id, id):
    payload = request.get_json()
    card = Card.deserialize(payload)
    card.id = id
    status_code, card_id = update_card(card)
    data = {'status': 'success', 'message': 'Updated card', 'resource_id': card_id}
    LOG.debug(card)
    activity = Activity(user_id, "MODIFY_CARD", payload)
    add_activity(activity)
    return make_response(jsonify(data), status_code)
Exemplo n.º 4
0
def create_list(user_id):
    payload = request.get_json()
    li = List.deserialize(payload)
    status_code, list_id = add_list(li)
    data = {
        'status': 'success',
        'message': 'Created new list',
        'resource_id': list_id
    }
    LOG.debug(li)
    activity = Activity(user_id, "CREATE_LIST", payload)
    add_activity(activity)
    return make_response(jsonify(data), status_code)
def create_board(user_id):
    payload = request.get_json()
    board = Board.deserialize(payload)
    board.user_id = user_id
    status_code, board_id = add_board(board)
    data = {
        'status': 'success',
        'message': 'Created new board',
        'resource_id': board_id
    }
    LOG.debug(board)
    activity = Activity(user_id, "CREATE_BOARD", payload)
    add_activity(activity)
    return make_response(jsonify(data), status_code)
Exemplo n.º 6
0
def modify_list(user_id, id):
    payload = request.get_json()
    li = List.deserialize(payload)
    li.id = id
    status_code, list_id = update_list(li)
    data = {
        'status': 'success',
        'message': 'Updated list',
        'resource_id': list_id
    }
    LOG.debug(li)
    activity = Activity(user_id, "MODIFY_LIST", payload)
    add_activity(activity)
    return make_response(jsonify(data), status_code)
def delete_comment(user_id, object_type, object_id):
    if object_type not in OBJECT_TYPES:
        status_code = 404
        data = {
            'status': 'failed',
            'message': 'Modifying comment failed, unsupported object type',
            'resource_id': object_id
        }
        return make_response(jsonify(data), status_code)
    status_code, comment_id = delete_comment(object_id)
    data = {
        'status': 'success',
        'message': 'Removed comment',
        'resource_id': comment_id
    }
    LOG.debug(data)
    activity = Activity(user_id, "DELETE_COMMENT", data)
    add_activity(activity)
    return make_response(jsonify(data), status_code)