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["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): 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 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["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 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["requestID"] is None: return {"success": False} with session_scope() as session: return { "success": (count_vehicles(session, args["requestID"]) > 0) }
def post(self): args = parser.parse_args() if args["shifts"] is None: return {"success": False} with session_scope() as session: for shift in args["shifts"]: for volunteer in shift['volunteers']: add_shift(session, volunteer['ID'], shift['shiftID'], volunteer['positionID'], volunteer['role']) return {"success": True}
def post(self): args = parser.parse_args() if args["requestID"] is None or args["vehicles"] is None: return {"success": False} with session_scope() as session: for v in args["vehicles"]: new_id = insert_vehicle(session, args["requestID"], v["assetClass"], v["startDateTime"], v["endDateTime"]) return {"success": True, 'id': new_id}
def get(self): args = parser.parse_args() if args["volunteerID"] is None: return {"success": False} with session_scope() as session: rtn = [] for row in get_request_by_volunteer(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 {"success": True, "results": rtn}
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 get_func(self, request_id): with session_scope() as session: o = [] rtn = [] for row in get_shifts_by_request(session, request_id): # 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()) # TODO: Tech Debt # - Find out what this code is trying to do for y in rtn: if y["ID"] == None: y["ID"] = "-1" n = True for i, x in enumerate(o): if x["shiftID"] == y["shiftID"]: o[i]["volunteers"].append({ "ID": y["ID"], "positionID": y["positionID"], "role": json.loads(y["role"]), "status": y["status"] }) n = False break if n: o.append({ "shiftID": y["shiftID"], "assetClass": y["assetClass"], "startTime": y["startTime"], "endTime": y["endTime"], "volunteers": [{ "ID": y["ID"], "positionID": y["positionID"], "role": y["role"], "status": y["status"] }] }) return {"results": o} return {"results": None}
def get(self): with session_scope() as session: res = get_existing_requests(session) return {"success": True, "results": res}