def post(self): args = check_args() if not args: return response("Room's name is required", 422) room = (Room.query.filter(Room.active == False).filter( Room.name == args["name"]).first()) if room: room.active = True room.lastUpdate = datetime.now() room.update() return schema.dump(room).data, 201 else: try: room = Room() room.name = args["name"] room.add(room) except SQLAlchemyError as e: return rollback(e, db), 406 else: return schema.dump(room).data, 201
User.query.delete() user = User(name="uName", email="*****@*****.**", uid="000000000", userType=UserTypesEnum.PROFESSOR) user.add(user) print("User ID {}\n".format(user.id)) room = Room() room.name = "E003" roomUser = RoomUser() roomUser.user = user room.users.append(roomUser) room.active = True room.add(room) print("Room ID {}\n".format(room.id)) schedule = Schedule() schedule.room = room schedule.userType = UserTypesEnum.PROFESSOR schedule.dayOfWeek = DaysOfWeekEnum.MONDAY schedule.beginTime = datetime.now().hour schedule.endTime = datetime.now().hour schedule.lastUpdate = datetime.now() schedule.active = True schedule.add(schedule) print("Schedule ID {}\n".format(schedule.id))