|
1 | 1 | from datetime import datetime |
2 | 2 |
|
3 | 3 | import jwt |
4 | | -from core.permissions import IsOwnerOrReadOnly |
5 | | -from core.utils import Email |
6 | 4 | from django.conf import settings |
7 | 5 | from django.contrib.auth import get_user_model |
8 | 6 | from django.contrib.sites.shortcuts import get_current_site |
| 7 | +from django.db.models import Q |
9 | 8 | from django.shortcuts import redirect |
10 | 9 | from django.urls import reverse |
11 | 10 | from django_filters import rest_framework as filters |
12 | 11 | from rest_framework import status |
13 | 12 | from rest_framework.generics import ( |
14 | 13 | GenericAPIView, |
| 14 | + ListAPIView, |
15 | 15 | ListCreateAPIView, |
16 | 16 | RetrieveUpdateDestroyAPIView, |
17 | 17 | UpdateAPIView, |
|
20 | 20 | from rest_framework.response import Response |
21 | 21 | from rest_framework_simplejwt.tokens import RefreshToken |
22 | 22 |
|
| 23 | +from core.permissions import IsOwnerOrReadOnly |
| 24 | +from core.utils import Email |
23 | 25 | from users.serializers import ( |
24 | 26 | EmailSerializer, |
25 | 27 | PasswordSerializer, |
@@ -69,6 +71,18 @@ def post(self, request, *args, **kwargs): |
69 | 71 | return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) |
70 | 72 |
|
71 | 73 |
|
| 74 | +class SpecialistsList(ListAPIView): |
| 75 | + """ |
| 76 | + This view returns a list of specialists: investors, experts and mentors. |
| 77 | + """ |
| 78 | + |
| 79 | + queryset = User.objects.filter( |
| 80 | + Q(user_type=User.EXPERT) | Q(user_type=User.MENTOR) | Q(user_type=User.INVESTOR) |
| 81 | + ) |
| 82 | + permission_classes = [IsAuthenticated] |
| 83 | + serializer_class = UserListSerializer |
| 84 | + |
| 85 | + |
72 | 86 | class UserDetail(RetrieveUpdateDestroyAPIView): |
73 | 87 | queryset = User.objects.all() |
74 | 88 | permission_classes = [IsOwnerOrReadOnly, IsAuthenticated] |
|
0 commit comments