From d88c1e2327da8665d48b91dc51f8b53be8ae3389 Mon Sep 17 00:00:00 2001 From: "C. Weaver" Date: Fri, 12 Jan 2024 12:58:18 -0500 Subject: [PATCH] Select the GroupMembershipCreationSerializer implementation based on the API version. Fixes #66. --- scimma_admin/hopskotch_auth/api_views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scimma_admin/hopskotch_auth/api_views.py b/scimma_admin/hopskotch_auth/api_views.py index b3ff81e..c0a80c6 100644 --- a/scimma_admin/hopskotch_auth/api_views.py +++ b/scimma_admin/hopskotch_auth/api_views.py @@ -960,7 +960,8 @@ def create(self, request, *args, **kwargs): logger.info(f"User {request.user.username} ({request.user.email}) " f"requested to add a member to group {kwargs.get('group','')} " f"from {client_ip(request)}") - serializer = GroupMembershipCreationSerializer(data=request.data) + version = self.kwargs.get("version",current_api_version) + serializer = serializers[version].GroupMembershipCreationSerializer(data=request.data) serializer.is_valid(raise_exception=True) print(f"validated_data: {serializer.validated_data}") @@ -970,8 +971,7 @@ def create(self, request, *args, **kwargs): if "group" not in kwargs: raise BadRequest # Not strictly required, but to keep things clear, require that the group to which the - # mmebership would be added match what was specified in the URL. - version = self.kwargs.get("version",current_api_version) + # membership would be added match what was specified in the URL. if version == 0 and group.id!=kwargs["group"]: raise BadRequest if version > 0 and group.name!=kwargs["group"]: