def post(self): args = parser.parse_args() with session_scope() as session: new_id = insert_vehicle(session, args["requestId"], args["assetType"], args["startDate"], args["endDate"]) return {"success": True, 'id': new_id}
def patch(self): args = role_parser.parse_args() if args['name'] is None or args['name'] == '': return with session_scope() as session: toggle_role(session, args['name']) return
def patch(self): args = qualification_parser.parse_args() if args['name'] is None or args['name'] == '': return with session_scope() as session: toggle_qualification(session, args['name']) return
def post(self): args = qualification_parser.parse_args() if args['name'] is None or args['name'] == '': return with session_scope() as session: role_id = add_qualification(session, args['name']) return {'id': role_id}
def post(self): args = parser.parse_args() if args["title"] is None: return with session_scope() as session: new_id = new_request(session, args["title"]) return {"id": new_id}
def get(self): args = parser.parse_args() if args["requestId"] is None: return with session_scope() as session: asset_requests = [] vehicles = get_vehicles(session, args['requestId']) for vehicle in vehicles: vehicle_id, asset_class, start_date, end_date = vehicle asset_requests.append({ "shiftID": vehicle_id, "assetClass": asset_class, "timeframe": (start_date, end_date) }) volunteers = list_volunteers(session) # Get the generated recommendation output = schedule(volunteers, asset_requests) if not output == []: print("Optimisation Succeeded") # Persist the optimisation! we don't ask the fkn front end to manage the backends data! This is completely # insane and the reason the front end is a cluster fk! for vehicle in output: vehicle_id = vehicle['shiftID'] for volunteer in vehicle['volunteers']: volunteer_id = volunteer['ID'] if volunteer_id == -1: volunteer_id = None position = volunteer['positionID'] role = volunteer['role'] add_shift(session, volunteer_id, vehicle_id, position, role) return {"results": output}
def patch(self): args = asset_type_parser.parse_args() if args['code'] is None or args['code'] == '': return with session_scope() as session: toggle_asset_type(session, args['code']) return
def patch(self): args = parser.parse_args() if args["volunteerID"] is None or args["prefHours"] is None: return {"success": False} with session_scope() as session: set_preferred_hours(session, args['volunteerID'], args["prefHours"]) return {"success": True}
def get(self): args = parser.parse_args() if args["volunteerID"] is None: return {"success": False} with session_scope() as session: res = get_volunteer(session, args['volunteerID']) return {"success": True, "prefHours": res.preferred_hours}
def get(self): with session_scope() as session: rtn = [] for row in list_volunteers(session): # Access protected _asdict() to return the keyed tuple as a dict to enable flask_restful to marshal # it correctly. The alternative method is less tidy. rtn.append(row._asdict()) return {"success": True, "results": rtn}
def get(self): args = parser.parse_args() if args["volunteerID"] is None: return {"success": False} with session_scope() as session: res = get_volunteer(session, args["volunteerID"]) return {"success": True, "availability": res.availabilities}
def post(self): args = asset_type_parser.parse_args() if args['name'] is None or args['name'] == '': return if args['code'] is None or args['code'] == '': return with session_scope() as session: asset_type_id = add_asset_type(session, args['code'], args['name']) return {'id': asset_type_id}
def get(self): args = parser.parse_args() if args["idVolunteer"] is None or args["idVehicle"] is None: return {"status": None, "success": False} with session_scope() as session: res = get_asset_request_volunteer(session, args["idVolunteer"], args["idVehicle"]) return {"success": True, "status": res.status}
def get(self): args = parser.parse_args() if args["requestId"] is None: return {"success": False} with session_scope() as session: return { "success": (count_vehicles(session, args["requestId"]) > 0) }
def post(self): request.get_json(force=True) args = registration_parser.parse_args() auth = AuthenticationService() with session_scope() as session: result = auth.register(session, args['email'], args['password'], args['given_name'], args['last_name'], args['phone']) return jsonify({"result": result.name})
def get(self): args = parser.parse_args() if args["volunteerID"] is None: return {"success": False} with session_scope() as session: rtn = [] for row in list_volunteers(session, args["volunteerID"]): # Access protected _asdict() to return the keyed tuple as a dict to enable flask_restful to marshal # it correctly. The alternative method is less tidy. rtn.append(row._asdict()) return rtn[0]
def patch(self): args = parser.parse_args() if args["volunteerID"] is None or args["availability"] is None: return {"success": False} try: json.dumps(args["availability"]) except: return {"success": False} with session_scope() as session: set_availabilities(session, args["volunteerID"], args["availability"]) return {"success": True}
def patch(self): args = parser.parse_args() if args["idVolunteer"] is None or args["idVehicle"] is None or args[ "status"] is None: return {"success": False} if args['status'] not in ["confirmed", "rejected"]: return {"success": False} with session_scope() as session: set_asset_request_volunteer_status(session, args['status'], args["idVolunteer"], args["idVehicle"]) return {"success": True}
def post(self): request.get_json(force=True) args = login_parser.parse_args() auth = AuthenticationService() with session_scope() as session: result, token, user = auth.login(session, args['email'], args['password']) if token is None: return jsonify({"result": result.name}) return jsonify({ "result": result.name, "access_token": token, "role": user.role.name, 'id': user.id })
def get(self): with session_scope() as session: res = get_existing_requests(session) return {"success": True, "results": res}
def delete(self): args = delete_parser.parse_args() with session_scope() as session: result = delete_request(session, args["requestID"]) return result
def get(self): with session_scope() as session: return get_qualifications(session)
def get(self): with session_scope() as session: return get_roles(session)
def delete(self): args = delete_parser.parse_args() with session_scope() as session: result = delete_vehicle(session, args["requestId"], args["vehicleID"]) return {"success": result}
def get(self): with session_scope() as session: return get_asset_type(session)