コード例 #1
0
 def test_delete_listing(self):
     username = '******'
     air_mail = models.Listing.objects.for_user(username).get(
         title='Air Mail')
     model_access.delete_listing(username, air_mail)
     self.assertEquals(0, models.Listing.objects.for_user(username).filter(
         title='Air Mail').count())
コード例 #2
0
ファイル: views.py プロジェクト: caseyrudge/ozp-backend
 def destroy(self, request, pk=None):
     """
     Delete a listing
     """
     queryset = self.get_queryset()
     listing = get_object_or_404(queryset, pk=pk)
     model_access.delete_listing(request.user.username, listing)
     return Response(status=status.HTTP_204_NO_CONTENT)
コード例 #3
0
 def destroy(self, request, pk=None):
     """
     Delete a listing
     """
     queryset = self.get_queryset()
     listing = get_object_or_404(queryset, pk=pk)
     model_access.delete_listing(request.user.username, listing)
     return Response(status=status.HTTP_204_NO_CONTENT)
コード例 #4
0
ファイル: views.py プロジェクト: gvsurenderreddy/ozp-backend
 def destroy(self, request, pk=None):
     """
     Delete a listing
     """
     queryset = self.get_queryset()
     listing = get_object_or_404(queryset, pk=pk)
     try:
         model_access.delete_listing(request.user.username, listing)
     except errors.PermissionDenied as e:
         return Response({'detail': 'Permission Denied', 'reason': str(e)}, status=status.HTTP_403_FORBIDDEN)
     return Response(status=status.HTTP_204_NO_CONTENT)
コード例 #5
0
 def test_delete_listing(self):
     username = '******'
     air_mail = models.Listing.objects.for_user(username).get(
         title='Air Mail')
     model_access.delete_listing(username, air_mail)
     self.assertEquals(
         1,
         models.Listing.objects.for_user(username).filter(
             title='Air Mail').count())
     self.assertTrue(
         models.Listing.objects.for_user(username).filter(
             title='Air Mail').first().is_deleted)
コード例 #6
0
ファイル: views.py プロジェクト: aml-development/ozp-backend
    def destroy(self, request, pk=None):
        """
        Delete a listing
        """
        queryset = self.get_queryset()
        listing = get_object_or_404(queryset, pk=pk)
        description = request.data['description'] if 'description' in request.data else None
        if not description:
            raise errors.InvalidInput('Description is required when deleting a listing')

        model_access.delete_listing(request.user.username, listing, description)
        return Response(status=status.HTTP_204_NO_CONTENT)
コード例 #7
0
    def test_delete_listing(self):
        username = '******'
        air_mail = models.Listing.objects.for_user(username).get(title='Air Mail')
        description = 'this app has been deleted'

        model_access.delete_listing(username, air_mail, description)
        self.assertEqual(1, models.Listing.objects.for_user(username).filter(title='Air Mail').count())
        self.assertTrue(models.Listing.objects.for_user(username).filter(title='Air Mail').first().is_deleted)

        listing_activities = air_mail.listing_activities.filter(action=models.ListingActivity.DELETED)
        deleted_activity = listing_activities[0]
        self.assertEqual(deleted_activity.author.user.username, username)
        self.assertEqual(deleted_activity.description, description)
コード例 #8
0
    def destroy(self, request, pk=None):
        """
        Delete a listing
        """
        queryset = self.get_queryset()
        listing = get_object_or_404(queryset, pk=pk)
        description = request.data[
            'description'] if 'description' in request.data else None
        if not description:
            raise errors.InvalidInput(
                'Description is required when deleting a listing')

        model_access.delete_listing(request.user.username, listing,
                                    description)
        return Response(status=status.HTTP_204_NO_CONTENT)