def task(): models = Task.query.order_by(Task.id.desc()).all() return jsonify({ "status": True, 'data': [to_dict(m, append_columns=['project_name']) for m in models] })
def project(): return_data = [] models = Project.query.order_by(Project.id.desc()).all() return jsonify({ 'status': True, 'data': [to_dict(m, append_columns=['machine_names']) for m in models] })
def machine(): query = Machine.query.order_by(Machine.id.desc()) print(request.args.get('name')) if request.args.get('name') != None and request.args.get('name') != '': query = query.filter('name like :name').params( name=request.args.get('name') + "%") models = query.all() return jsonify({ "status": True, "data": [to_dict(m, append_columns=['cpu', 'mem']) for m in models] })
def user_profile(): one = User.query.get(g.user_id) return jsonify({'status': True, 'data': to_dict(one, ['id', 'username', 'created_at'])})
def user(): users = User.query.order_by(User.id.desc()).all() return jsonify({'status': True, 'data': [to_dict(obj, ['id', 'username', 'created_at']) for obj in users]})