[chore] Global project refactoring

This commit is contained in:
ITQ
2024-04-01 11:20:07 +03:00
parent 0a8b3773f5
commit 5c64e1f3b9
49 changed files with 731 additions and 496 deletions
+26
View File
@@ -0,0 +1,26 @@
from backend.project.users.models import User
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from teams.models import Team
from .serializers import TeamSerializer
class AddUserToTeam(APIView):
def post(self, request, team_id, user_id): # noqa: ARG002
try:
team = Team.objects.get(id=team_id)
user = User.objects.get(id=user_id)
except Team.DoesNotExist:
return Response(
{"error": "Team not found"}, status=status.HTTP_404_NOT_FOUND
)
except User.DoesNotExist:
return Response(
{"error": "User not found"}, status=status.HTTP_404_NOT_FOUND
)
team.members.add(user)
team_serializer = TeamSerializer(team)
return Response(team_serializer.data, status=status.HTTP_200_OK)