def make_seats(importstep: arm.Importstep, roomname: str, numseats: int) -> tg.Tuple[arm.Seat, ...]: results = [] room = arm.Room(organization="org", department="dep", building="bldg", room=roomname, seat_last=arm.Seat.form_seatname(1, numseats), importstep=importstep) room.save() for i in range(numseats): seat = arm.Seat(hash=arm.Seat.seathash( room, arm.Seat.form_seatname(1, i + 1)), rownumber=1, seatnumber=i + 1, room=room) seat.save() results.append(seat) return tuple(results)
def _mursv_seats(importstep: arm.Importstep, roomname: str, seat_last: str) -> tg.Tuple[arm.Room, tg.Sequence[arm.Seat]]: seats = [] room = arm.Room(organization=f"org{random.randint(1000,9999)}", department="dep", building="bldg", row_dist=1.2, seat_dist=0.7, room=roomname, seat_last=seat_last, importstep=importstep) room.save() maxrow, maxseat = arm.Seat.split_seatname(seat_last) for r in range(1, maxrow + 1): for s in range(1, maxseat + 1): seatname = arm.Seat.form_seatname(r, s) seat = arm.Seat(hash=arm.Seat.seathash(room, seatname), rownumber=r, seatnumber=s, room=room) seat.save() seats.append(seat) return (room, seats)
def make_seats(roomname: str, numseats: int, organization="org", department="dep") -> tg.Tuple[arm.Seat, ...]: importstep = arm.Importstep.objects.first() # reuse existing, if any if not importstep: user = aum.User.objects.first() or aum.User.objects.create(name="x") importstep = arm.Importstep(user=user) importstep.save() results = [] room = arm.Room(organization=organization, department=department, building="bldg", room=roomname, row_dist=1.3, seat_dist=0.8, seat_last=arm.Seat.form_seatname(1, numseats), importstep=importstep) room.save() for i in range(numseats): seat = arm.Seat( hash=arm.Seat.seathash(room, arm.Seat.form_seatname(1, i + 1)), rownumber=1, seatnumber=i + 1, room=room) seat.save() results.append(seat) return tuple(results)