Beispiel #1
0
    def __init__(self, *args, **kwargs):
        controller_id = kwargs.pop(CONTROLLER_ID, None)
        super(DoorDetachControllerForm, self).__init__(*args, **kwargs)

        if controller_id:
            self.fields[CONTROLLER_ID] = forms.IntegerField(widget=forms.HiddenInput, initial=controller_id)
            doors = ControllerService.get_doors(id=controller_id)
            self.fields[DOORS].queryset = doors
        self.fields[DOORS].empty_label = None
Beispiel #2
0
 def get(self, request: HttpRequest, id: str):
     id = self.parse_int_pk(id)
     doors = ControllerService.get_doors(id)
     door_dtos = list([DoorOutDto.from_door(d) for d in doors])
     return ApiResponse.success(door_dtos)
 def get_queryset(self):
     try:
         return ControllerService.get_doors(id=self.get_obj_id())
     except:
         raise Http404