Skip to content

Commit

Permalink
Repo summary view | Reusing mixins | removed unused base class
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jul 31, 2024
1 parent 9a0b339 commit 716f496
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
31 changes: 4 additions & 27 deletions core/collections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from core.mappings.documents import MappingDocument
from core.mappings.models import Mapping
from core.mappings.search import MappingFacetedSearch
from core.sources.mixins import SummaryMixin
from core.tasks.mixins import TaskMixin
from core.tasks.models import Task
from core.tasks.serializers import TaskListSerializer
Expand Down Expand Up @@ -1047,7 +1048,7 @@ def handle_export_version(self):
return status.HTTP_409_CONFLICT


class CollectionSummaryView(CollectionBaseView, RetrieveAPIView, CreateAPIView):
class CollectionSummaryView(SummaryMixin, CollectionBaseView, RetrieveAPIView):
serializer_class = CollectionSummaryDetailSerializer
permission_classes = (CanViewConceptDictionary,)

Expand All @@ -1058,20 +1059,8 @@ def get_serializer_class(self):
return CollectionSummaryVerboseSerializer
return CollectionSummaryDetailSerializer

def get_object(self, queryset=None):
instance = get_object_or_404(self.get_queryset())
self.check_object_permissions(self.request, instance)
return instance

def put(self, request, **kwargs): # pylint: disable=unused-argument
instance = self.get_object()
if instance.has_edit_access(request.user):
instance.update_children_counts()
return Response(status=status.HTTP_202_ACCEPTED)
raise PermissionDenied()


class CollectionVersionSummaryView(CollectionBaseView, RetrieveAPIView):
class CollectionVersionSummaryView(SummaryMixin, CollectionBaseView, RetrieveAPIView):
serializer_class = CollectionVersionSummaryDetailSerializer
permission_classes = (CanViewConceptDictionary,)

Expand All @@ -1082,20 +1071,8 @@ def get_serializer_class(self):
return CollectionVersionSummaryVerboseSerializer
return CollectionVersionSummaryDetailSerializer

def get_object(self, queryset=None):
instance = get_object_or_404(self.get_queryset())
self.check_object_permissions(self.request, instance)
return instance

def put(self, request, **kwargs): # pylint: disable=unused-argument
instance = self.get_object()
if instance.has_edit_access(request.user):
instance.update_children_counts()
return Response(status=status.HTTP_202_ACCEPTED)
raise PermissionDenied()


class CollectionLatestVersionSummaryView(CollectionVersionBaseView, RetrieveAPIView, UpdateAPIView):
class CollectionLatestVersionSummaryView(CollectionVersionBaseView, RetrieveAPIView):
serializer_class = CollectionVersionSummaryDetailSerializer
permission_classes = (CanViewConceptDictionary,)

Expand Down
2 changes: 1 addition & 1 deletion core/sources/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def get_serializer_class(self):
return SourceVersionSummaryDetailSerializer


class SourceLatestVersionSummaryView(SourceVersionBaseView, RetrieveAPIView, UpdateAPIView):
class SourceLatestVersionSummaryView(SourceVersionBaseView, RetrieveAPIView):
serializer_class = SourceVersionSummaryDetailSerializer
permission_classes = (CanViewConceptDictionary,)

Expand Down

0 comments on commit 716f496

Please sign in to comment.