Ejemplo n.º 1
0
def update(board_user_id: str, ver: str):
    session.rollback()
    data = deepcopy(request.data)
    data.update({"updated_by_id": request.user["id"]})
    old_data = query_helper.find_by_params(session,
                                           BoardUser, [{
                                               "id": {
                                                   "$eq": board_user_id
                                               }
                                           }, {
                                               "ver": {
                                                   "$eq": ver
                                               }
                                           }],
                                           json_result=True)
    result = query_helper.update_by_params(session,
                                           BoardUser, [{
                                               "id": {
                                                   "$eq": board_user_id
                                               }
                                           }, {
                                               "ver": {
                                                   "$eq": ver
                                               }
                                           }],
                                           data,
                                           json_result=True)
    log_helper.log_update(session, BoardUser, request.user["id"], result,
                          old_data)
    session.commit()
    return json_dumps(model_helper.insert_field_objects(session, result))
Ejemplo n.º 2
0
def update(user_id: str, ver: str):
    session.rollback()
    data = deepcopy(request.data)
    data.update({
        "updated_by_id": request.user["id"],
        "updated_at": datetime.now()
    })

    if 'password' in data:
        del data['password']

    old_data = query_helper.find_by_params(session,
                                           User, [{
                                               "id": {
                                                   "$eq": user_id
                                               }
                                           }, {
                                               "ver": {
                                                   "$eq": ver
                                               }
                                           }],
                                           json_result=True)

    result = query_helper.update_by_params(session,
                                           User, [{
                                               "id": {
                                                   "$eq": user_id
                                               }
                                           }, {
                                               "ver": {
                                                   "$eq": ver
                                               }
                                           }],
                                           data,
                                           json_result=True)
    log_helper.log_update(session, User, request.user["id"], result, old_data)
    session.commit()
    return json_dumps(model_helper.insert_field_objects(session, result))