コード例 #1
0
 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}
コード例 #2
0
    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}
コード例 #3
0
    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}
コード例 #4
0
 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}
コード例 #5
0
    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}
コード例 #6
0
    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}
コード例 #7
0
ファイル: vehicle_request.py プロジェクト: Ines923/FireApp2.0
    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)
            }
コード例 #8
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}
コード例 #9
0
ファイル: vehicle_request.py プロジェクト: Ines923/FireApp2.0
    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}
コード例 #10
0
    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}
コード例 #11
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}
コード例 #12
0
    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}
コード例 #13
0
    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}
コード例 #14
0
 def get(self):
     with session_scope() as session:
         res = get_existing_requests(session)
         return {"success": True, "results": res}