Skip to content

Commit

Permalink
Merge 5e2e99e into dbeebb1
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipotieno committed May 7, 2019
2 parents dbeebb1 + 5e2e99e commit 5b0e2af
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
9 changes: 0 additions & 9 deletions authors/apps/profiles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,3 @@ class FollowingSerializer(serializers.ModelSerializer):
class Meta:
model = Followers
fields = ('profile', 'followed')


class UserListSerializer(serializers.ModelSerializer):
"""
Serializer class for getting user profile
"""
class Meta:
model = Profile
fields = '__all__'
10 changes: 0 additions & 10 deletions authors/apps/profiles/tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ def test_successfully_listing_profiles(self):
"""
Test listing of user profiles
"""
self.is_authenticated("adam@gmail.com", "@Us3r.com")
response = self.list_profiles()
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIsInstance(response.data.get("profiles")[0], dict)

def test_listing_profiles_with_unauthorised_user(self):
"""
Test listing of user profiles with unauthorised user
"""
response = self.list_profiles()
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(response.data.get("detail"),
"Authentication credentials were not provided.")
5 changes: 2 additions & 3 deletions authors/apps/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from authors.apps.authentication.models import User
from django.shortcuts import get_object_or_404

from .serializers import UserProfileSerializer, UpdateUserProfileSerializer, FollowingSerializer, UserListSerializer
from .serializers import UserProfileSerializer, UpdateUserProfileSerializer, FollowingSerializer
from .models import Profile, Followers
from .renderers import FollowersJSONRenderer

Expand Down Expand Up @@ -202,11 +202,10 @@ class UserListView(GenericAPIView):
"""
A class for getting all user profiles
"""
permission_classes = [permissions.IsAuthenticated]

def get(self, request):
queryset = Profile.objects.all()
serializer = UserListSerializer(queryset, many=True)
serializer = UserProfileSerializer(queryset, many=True)
return Response({
'profiles': serializer.data
}, status=status.HTTP_200_OK)

0 comments on commit 5b0e2af

Please sign in to comment.