Skip to content

Commit

Permalink
Select the GroupMembershipCreationSerializer implementation based on …
Browse files Browse the repository at this point in the history
…the API version.

Fixes #66.
  • Loading branch information
C. Weaver committed Jan 12, 2024
1 parent 84d9469 commit d88c1e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scimma_admin/hopskotch_auth/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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','<missing>')} "
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}")
Expand All @@ -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"]:
Expand Down

0 comments on commit d88c1e2

Please sign in to comment.