1010from onegov .api import ApiEndpoint , ApiInvalidParamException
1111from onegov .api .utils import is_authorized
1212from onegov .gis import Coordinates
13+ from uuid import UUID
1314
1415
1516from typing import Any
@@ -97,7 +98,7 @@ def get_modified_iso_format(item: TimestampMixin) -> str:
9798 return item .last_change .isoformat ()
9899
99100
100- class PersonApiEndpoint (ApiEndpoint ['ExtendedPerson' ], ApisMixin ):
101+ class PersonApiEndpoint (ApiEndpoint ['ExtendedPerson' , UUID ], ApisMixin ):
101102 request : CoreRequest
102103 app : AgencyApp
103104 endpoint = 'people'
@@ -106,6 +107,7 @@ class PersonApiEndpoint(ApiEndpoint['ExtendedPerson'], ApisMixin):
106107 'last_name' : None
107108 } | dict .fromkeys (UPDATE_FILTER_PARAMS , UPDATE_FILTER_PROMPT )
108109 form_class = AuthenticatedPersonMutationForm
110+ pk_type = UUID
109111
110112 @property
111113 def title (self ) -> str :
@@ -211,14 +213,15 @@ def apply_changes(
211213 do_report_person_change (item , form .meta .request , form )
212214
213215
214- class AgencyApiEndpoint (ApiEndpoint ['ExtendedAgency' ], ApisMixin ):
216+ class AgencyApiEndpoint (ApiEndpoint ['ExtendedAgency' , int ], ApisMixin ):
215217 request : CoreRequest
216218 app : AgencyApp
217219 endpoint = 'agencies'
218220 filters = {
219221 'parent' : None ,
220222 'title' : None
221223 } | dict .fromkeys (UPDATE_FILTER_PARAMS , UPDATE_FILTER_PROMPT )
224+ pk_type = int
222225
223226 @property
224227 def title (self ) -> str :
@@ -229,7 +232,7 @@ def collection(self) -> PaginatedAgencyCollection:
229232 result = PaginatedAgencyCollection (
230233 self .session ,
231234 page = self .page or 0 ,
232- parent = self .get_filter ('parent' , None , False ),
235+ parent = self .get_filter ('parent' , None , False , coerce = int ),
233236 joinedload = ['organigram' , 'parent' ],
234237 undefer = ['content' ]
235238 )
@@ -279,7 +282,7 @@ def item_links(self, item: ExtendedAgency) -> dict[str, Any]:
279282
280283
281284class MembershipApiEndpoint (
282- ApiEndpoint ['ExtendedAgencyMembership' ],
285+ ApiEndpoint ['ExtendedAgencyMembership' , UUID ],
283286 ApisMixin
284287):
285288
@@ -290,14 +293,15 @@ class MembershipApiEndpoint(
290293 'agency' : None ,
291294 'person' : None
292295 } | dict .fromkeys (UPDATE_FILTER_PARAMS , UPDATE_FILTER_PROMPT )
296+ pk_type = UUID
293297
294298 @property
295299 def collection (self ) -> PaginatedMembershipCollection :
296300 result = PaginatedMembershipCollection (
297301 self .session ,
298302 page = self .page or 0 ,
299- agency = self .get_filter ('agency' ),
300- person = self .get_filter ('person' ),
303+ agency = self .get_filter ('agency' , coerce = int ),
304+ person = self .get_filter ('person' , coerce = UUID ),
301305 )
302306
303307 for key , values in self .extra_parameters .items ():
0 commit comments