|
1 | 1 | import urllib.parse |
2 | 2 |
|
3 | 3 | import jwt |
4 | | -import requests |
5 | 4 | from django.apps import apps |
6 | 5 | from django.conf import settings |
7 | 6 | from django.contrib.auth import get_user_model |
|
54 | 53 | AchievementDetailSerializer, |
55 | 54 | AchievementListSerializer, |
56 | 55 | PublicUserSerializer, |
57 | | - RemoteBuySubSerializer, |
58 | 56 | ResendVerifyEmailSerializer, |
59 | 57 | SpecializationSerializer, |
60 | 58 | SpecializationsSerializer, |
61 | 59 | UserApproveSkillResponse, |
62 | | - UserCloneDataSerializer, |
63 | 60 | UserDetailSerializer, |
64 | 61 | UserListSerializer, |
65 | 62 | UserProjectListSerializer, |
66 | 63 | UserSkillConfirmationSerializer, |
67 | 64 | UserSubscribedProjectsSerializer, |
68 | | - UserSubscriptionDataSerializer, |
69 | 65 | VerifyEmailSerializer, |
70 | 66 | ) |
71 | 67 | from users.typing import UserCVDataV2 |
@@ -261,31 +257,7 @@ class CurrentUser(GenericAPIView): |
261 | 257 | def get(self, request): |
262 | 258 | user = request.user |
263 | 259 | serializer = self.get_serializer(user) |
264 | | - |
265 | | - if settings.DEBUG: |
266 | | - skills_url_name = ( |
267 | | - "https://skills.dev.procollab.ru/progress/subscription-data/" |
268 | | - ) |
269 | | - else: |
270 | | - skills_url_name = ( |
271 | | - "https://api.skills.procollab.ru/progress/subscription-data/" |
272 | | - ) |
273 | | - try: |
274 | | - subscription_data = requests.get( |
275 | | - skills_url_name, |
276 | | - headers={ |
277 | | - "accept": "application/json", |
278 | | - "Authorization": request.META.get("HTTP_AUTHORIZATION"), |
279 | | - }, |
280 | | - ) |
281 | | - subscription_serializer = UserSubscriptionDataSerializer( |
282 | | - subscription_data.json() |
283 | | - ) |
284 | | - subs_data = subscription_serializer.data |
285 | | - except Exception: |
286 | | - subs_data = {} |
287 | | - |
288 | | - return Response(serializer.data | subs_data, status=status.HTTP_200_OK) |
| 260 | + return Response(serializer.data, status=status.HTTP_200_OK) |
289 | 261 |
|
290 | 262 |
|
291 | 263 | class UserTypesView(APIView): |
@@ -575,82 +547,6 @@ def get_queryset(self): |
575 | 547 | return Specialization.objects.all() |
576 | 548 |
|
577 | 549 |
|
578 | | -class SingleUserDataView(ListAPIView): |
579 | | - serializer_class = UserCloneDataSerializer |
580 | | - permissions = [AllowAny] |
581 | | - authentication_off = True |
582 | | - |
583 | | - def get_queryset(self) -> User: |
584 | | - return [get_object_or_404(User, email=self.request.data["email"])] |
585 | | - |
586 | | - |
587 | | -class RemoteViewSubscriptions(APIView): |
588 | | - permission_classes = [AllowAny] |
589 | | - |
590 | | - def get(self, request, *args, **kwargs): |
591 | | - try: |
592 | | - subscriptions = self._get_response_from_remote_api() |
593 | | - return Response(subscriptions, status=status.HTTP_200_OK) |
594 | | - except requests.RequestException as e: |
595 | | - return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) |
596 | | - |
597 | | - def _get_link_to_remote_api(self) -> str: |
598 | | - # TODO something to reuse this code |
599 | | - if settings.DEBUG: |
600 | | - subscriptions_url = "https://skills.dev.procollab.ru/subscription/" |
601 | | - else: |
602 | | - subscriptions_url = "https://api.skills.procollab.ru/subscription/" |
603 | | - return subscriptions_url |
604 | | - |
605 | | - def _get_response_from_remote_api(self): |
606 | | - subscriptions_url = self._get_link_to_remote_api() |
607 | | - response = requests.get( |
608 | | - subscriptions_url, |
609 | | - headers={ |
610 | | - "accept": "application/json", |
611 | | - "Authorization": self.request.META.get("HTTP_AUTHORIZATION"), |
612 | | - }, |
613 | | - ) |
614 | | - response.raise_for_status() |
615 | | - return response.json() |
616 | | - |
617 | | - |
618 | | -class RemoteCreatePayment(GenericAPIView): |
619 | | - serializer_class = RemoteBuySubSerializer |
620 | | - permission_classes = [AllowAny] |
621 | | - |
622 | | - def post(self, request, *args, **kwargs): |
623 | | - try: |
624 | | - subscriptions_buy_url = self._get_link_to_remote_api() |
625 | | - data, headers = self._get_data_to_request_remote_api() |
626 | | - response = requests.post(subscriptions_buy_url, json=data, headers=headers) |
627 | | - response.raise_for_status() |
628 | | - return Response(response.json(), status=status.HTTP_200_OK) |
629 | | - except requests.RequestException as e: |
630 | | - return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) |
631 | | - |
632 | | - def _get_link_to_remote_api(self) -> str: |
633 | | - # TODO something to reuse this code |
634 | | - if settings.DEBUG: |
635 | | - subscriptions_buy_url = "https://skills.dev.procollab.ru/subscription/buy/" |
636 | | - else: |
637 | | - subscriptions_buy_url = "https://api.skills.procollab.ru/subscription/buy/" |
638 | | - return subscriptions_buy_url |
639 | | - |
640 | | - def _get_data_to_request_remote_api(self) -> tuple[dict, dict]: |
641 | | - serializer = self.serializer_class(data=self.request.data) |
642 | | - if serializer.is_valid(): |
643 | | - data = serializer.validated_data |
644 | | - headers = { |
645 | | - "accept": "application/json", |
646 | | - "Authorization": self.request.META.get("HTTP_AUTHORIZATION"), |
647 | | - } |
648 | | - return data, headers |
649 | | - |
650 | | - else: |
651 | | - return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
652 | | - |
653 | | - |
654 | 550 | class UserCVDownload(APIView): |
655 | 551 | permission_classes = [IsAuthenticated] |
656 | 552 |
|
|
0 commit comments