def __init__(self, *args, **kwargs): person_id = kwargs.pop('person_id', None) super(RoleDetachForm, self).__init__(*args, **kwargs) if person_id: self.fields['person_id'].initial = person_id roles = PersonService.get_roles(id=person_id) self.fields['roles'].queryset = roles self.fields['roles'].empty_label = None
def get_table() -> Table: persons = PersonService.get_all() data = [] for person in persons: data.append({ 'person': person, 'keys': PersonService.get_keys(id=person.id), 'roles': PersonService.get_roles(id=person.id) }) return PersonHomePageTable(data=data)
def get(self, request: HttpRequest, id: str): id = self.parse_int_pk(id) roles = PersonService.get_roles(id) key_dtos = list([RoleOutDto.from_role(r) for r in roles]) return ApiResponse.success(key_dtos)
def get_queryset(self): try: return PersonService.get_roles(id=self.get_obj_id()) except: raise Http404("Roles does not exist")