From 624bbdfebd0c627141559a921254778b42fdc9f9 Mon Sep 17 00:00:00 2001 From: darloof Date: Fri, 1 Mar 2024 20:19:49 +0330 Subject: [PATCH] [fix] contract approvement with team hidden_id --- psycity/team_api/serializers.py | 2 +- psycity/team_api/views/contract.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/psycity/team_api/serializers.py b/psycity/team_api/serializers.py index 5355600..0a1b805 100644 --- a/psycity/team_api/serializers.py +++ b/psycity/team_api/serializers.py @@ -279,7 +279,7 @@ class Meta: ) def validate_team(self, pk): - if len(str(pk)) == 10: + if len(str(pk)) == 12: team = Team.objects.get(hidden_id=pk) else: team = Team.objects.get(pk=pk) diff --git a/psycity/team_api/views/contract.py b/psycity/team_api/views/contract.py index c581508..a78b72c 100644 --- a/psycity/team_api/views/contract.py +++ b/psycity/team_api/views/contract.py @@ -87,9 +87,23 @@ class Approvement( second_party_agree=False, state=1 ) + team_query_set = Team.objects.all() @response def partial_update(self, request, *args, **kwargs): + if request.data.get('team'): + if len(str(request.data.get('team'))) == 12: + team = self.team_query_set.filter(hidden_id=request.data.get('team')) + if not team: + return Response( + data={ + "message": "team not found.", + "data": [], + "result": None, + }, + status=status.HTTP_404_NOT_FOUND, + ) + request.data['team'] = team.first().channel_role super().partial_update(request, *args, **kwargs) return Response( data={