Ejemplo n.º 1
0
def detach_door(controller_id: int, door_id: int):
    controller = get(controller_id)
    door = DoorService.get(door_id)
    if controller.doors.filter(id=door_id) == 0:
        raise exceptions.DoorNotFound
    try:
        controller.doors.remove(door)
    except:
        raise exceptions.ControllerManageFailed
Ejemplo n.º 2
0
def detach_door(place_id: int, door_id: int):
    place = get(place_id)
    door = DoorService.get(door_id)
    if place.doors.filter(id=door_id).count() == 0:
        raise exceptions.PlaceManageFailed
    try:
        place.doors.remove(door)
    except:
        raise exceptions.PlaceManageFailed
Ejemplo n.º 3
0
def attach_door(controller_id: int, door_id: int):
    controller = get(controller_id)
    door = DoorService.get(door_id)
    if controller.doors.filter(id=door_id).count() > 0:
        raise exceptions.DoorNotFound
    try:
        controller.doors.add(door)
    except:
        raise exceptions.ControllerManageFailed
Ejemplo n.º 4
0
 def get(self, request: HttpRequest, id: str):
     id = self.parse_int_pk(id)
     door = DoorService.get(id)
     return ApiResponse.success(DoorOutDto.from_door(door))