From 193ecfba7a4a7ea22e07d70683f8fde8c7aea80e Mon Sep 17 00:00:00 2001 From: Anatoly Date: Fri, 20 Sep 2019 15:38:20 +0300 Subject: [PATCH] fixed comments --- apps/collection/views/common.py | 9 --------- apps/establishment/serializers/common.py | 2 +- apps/establishment/views/web.py | 25 ------------------------ 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/apps/collection/views/common.py b/apps/collection/views/common.py index 8c386930..8d2eb109 100644 --- a/apps/collection/views/common.py +++ b/apps/collection/views/common.py @@ -47,15 +47,6 @@ class CollectionEstablishmentListView(CollectionListView): """ queryset = super(CollectionEstablishmentListView, self).get_queryset() # Perform the lookup filtering. - lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field - - assert lookup_url_kwarg in self.kwargs, ( - 'Expected view %s to be called with a URL keyword argument ' - 'named "%s". Fix your URL conf, or set the `.lookup_field` ' - 'attribute on the view correctly.' % - (self.__class__.__name__, lookup_url_kwarg) - ) - collection = get_object_or_404(queryset, pk=self.kwargs['pk']) # May raise a permission denied diff --git a/apps/establishment/serializers/common.py b/apps/establishment/serializers/common.py index 56583ba2..65522942 100644 --- a/apps/establishment/serializers/common.py +++ b/apps/establishment/serializers/common.py @@ -263,7 +263,7 @@ class EstablishmentCommentCreateSerializer(comment_serializers.CommentSerializer establishment_id = self.context.get('request').parser_context.get('kwargs').get('pk') establishment_qs = models.Establishment.objects.filter(id=establishment_id) if not establishment_qs.exists(): - return serializers.ValidationError() + raise serializers.ValidationError({'detail': _('Establishment not found.')}) attrs['establishment'] = establishment_qs.first() return attrs diff --git a/apps/establishment/views/web.py b/apps/establishment/views/web.py index daa26d6a..53382be9 100644 --- a/apps/establishment/views/web.py +++ b/apps/establishment/views/web.py @@ -79,14 +79,6 @@ class EstablishmentCommentRUDView(generics.RetrieveUpdateDestroyAPIView): Returns the object the view is displaying. """ queryset = self.filter_queryset(self.get_queryset()) - lookup_url_kwargs = ('pk', 'comment_id') - - assert lookup_url_kwargs in self.kwargs.keys(), ( - 'Expected view %s to be called with a URL keyword argument ' - 'named "%s". Fix your URL conf, or set the `.lookup_field` ' - 'attribute on the view correctly.' % - (self.__class__.__name__, lookup_url_kwargs) - ) establishment_obj = get_object_or_404(queryset, pk=self.kwargs['pk']) @@ -107,14 +99,6 @@ class EstablishmentFavoritesCreateDestroyView(generics.CreateAPIView, generics.D """ Returns the object the view is displaying. """ - lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field - assert lookup_url_kwarg in self.kwargs, ( - 'Expected view %s to be called with a URL keyword argument ' - 'named "%s". Fix your URL conf, or set the `.lookup_field` ' - 'attribute on the view correctly.' % - (self.__class__.__name__, lookup_url_kwarg) - ) - obj = get_object_or_404( self.request.user.favorites.by_content_type(app_label='establishment', model='establishment') @@ -164,15 +148,6 @@ class EstablishmentScheduleRUDView(generics.RetrieveUpdateDestroyAPIView): """ Returns the object the view is displaying. """ - lookup_url_kwargs = ('pk', 'schedule_id') - - assert lookup_url_kwargs in self.kwargs.keys(), ( - 'Expected view %s to be called with a URL keyword argument ' - 'named "%s". Fix your URL conf, or set the `.lookup_field` ' - 'attribute on the view correctly.' % - (self.__class__.__name__, lookup_url_kwargs) - ) - establishment_pk = self.kwargs['pk'] schedule_id = self.kwargs['schedule_id']