Exemplo n.º 1
0
def get_app(app_id):
    user_ID = get_jwt_identity()
    yml = request.args.get('yml')
    commits = request.args.get('commits')
    version = request.args.get('version')
    used_modules = request.args.get('used_modules')
    used_datasets = request.args.get('used_datasets')
    app = AppService.get_by_id(app_id,
                               yml=yml,
                               commits=commits,
                               version=version,
                               used_modules=used_modules)

    # 如果是私有项目,需要确定其登陆才能查看,否则返回error
    if app.privacy == 'private' and app.user.user_ID != user_ID:
        return jsonify({'response': 'error'}), 200

    # 将app.user 更换为 user_ID 还是name?
    user_ID = app.user.user_ID
    if used_modules == 'true':
        app = convert_used_modules(app)
    if used_datasets == 'true':
        app = convert_used_datasets(app)
    if used_modules != 'true' and used_datasets != 'true':
        app = json_utility.convert_to_json(app.to_mongo())
    app["user_ID"] = user_ID
    app["commits"].reverse()
    return jsonify({"response": app}), 200
Exemplo n.º 2
0
def get_app(app_id):
    yml = request.args.get('yml')
    commits = request.args.get('commits')
    app = AppService.get_by_id(app_id, yml=yml, commits=commits)

    # 将app.user 更换为 user_ID 还是name?
    user_ID = app.user.user_ID
    app = json_utility.convert_to_json(app.to_mongo())
    app["user_ID"] = user_ID
    return jsonify({"response": app}), 200