|
17 | 17 | from rest_framework.response import Response |
18 | 18 | from simple_history.utils import update_change_reason |
19 | 19 |
|
| 20 | +from apps.accounts.models import PeopleGroupLocation |
20 | 21 | from apps.accounts.permissions import HasBasePermission |
| 22 | +from apps.accounts.serializers import LocationPeopleGroupSerializer |
21 | 23 | from apps.analytics.models import Stat |
22 | 24 | from apps.commons.cache import clear_cache_with_key, redis_cache_view |
23 | 25 | from apps.commons.permissions import IsOwner, ReadOnly |
|
43 | 45 | ) |
44 | 46 | from services.mistral.models import ProjectEmbedding |
45 | 47 |
|
46 | | -from .filters import LocationFilter, ProjectFilter |
| 48 | +from .filters import ProjectFilter |
47 | 49 | from .models import ( |
48 | 50 | BlogEntry, |
49 | 51 | Goal, |
@@ -612,11 +614,6 @@ def dispatch(self, request, *args, **kwargs): |
612 | 614 | return super(LocationViewSet, self).dispatch(request, *args, **kwargs) |
613 | 615 |
|
614 | 616 |
|
615 | | -class ReadLocationViewSet(LocationViewSet): |
616 | | - http_method_names = ["get", "list"] |
617 | | - filterset_class = LocationFilter |
618 | | - |
619 | | - |
620 | 617 | class HistoricalProjectViewSet(MultipleIDViewsetMixin, viewsets.ReadOnlyModelViewSet): |
621 | 618 | lookup_field = "pk" |
622 | 619 | permission_classes = [ReadOnly] |
@@ -1004,3 +1001,22 @@ def add_image_to_model(self, image, *args, **kwargs): |
1004 | 1001 | tab_item.save() |
1005 | 1002 | return f"/v1/project/{self.kwargs['project_id']}/tab/{self.kwargs['tab_id']}/item-image/{image.id}" |
1006 | 1003 | return None |
| 1004 | + |
| 1005 | + |
| 1006 | +class GeneralLocationView(viewsets.GenericViewSet): |
| 1007 | + http_method_names = ["get", "list"] |
| 1008 | + |
| 1009 | + def list(self, request, *args, **kwargs): |
| 1010 | + qs_project = self.request.user.get_project_related_queryset( |
| 1011 | + Location.objects |
| 1012 | + ).select_related("project") |
| 1013 | + |
| 1014 | + qs_group = self.request.user.get_people_group_related_queryset( |
| 1015 | + PeopleGroupLocation.objects |
| 1016 | + ).select_related("people_group") |
| 1017 | + |
| 1018 | + data = { |
| 1019 | + "groups": LocationPeopleGroupSerializer(qs_group, many=True).data, |
| 1020 | + "projects": LocationSerializer(qs_project, many=True).data, |
| 1021 | + } |
| 1022 | + return Response(data, status=status.HTTP_200_OK) |
0 commit comments