Fakultas Ilmu Komputer UI

Commit b231b451 authored by Ami's avatar Ami
Browse files

changing 'username' attributes to 'name'

parent 1dea0ac1
Pipeline #79196 passed with stages
in 10 minutes and 21 seconds
......@@ -173,7 +173,7 @@ class GetProfilesAndCSVTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_get_specific_user(self):
response = self.client.get("/profiles/?username=tesb")
response = self.client.get("/profiles/?name=tesb")
expected_response = []
users = CustomUser.objects.filter(name="tesb")
......
......@@ -19,7 +19,7 @@ class GetProfilesViewSet(generics.ListAPIView):
def get_queryset(self):
"""
Optionally restricts the returned purchases to a given user,
by filtering against a `username` query parameter in the URL.
by filtering against a `name` query parameter in the URL.
"""
groups = self.request.user.groups.values_list('name',flat = True) # QuerySet Object
groups_list = list(groups) # QuerySet to `list`
......@@ -31,10 +31,10 @@ class GetProfilesViewSet(generics.ListAPIView):
queryset = queryset.filter(
Q(nutritionist=nutritionist_id) & ~Q(id=self.request.user.id))
username = self.request.query_params.get('username')
if username is not None:
u_capital = username.capitalize()
u_lower = username.lower()
name = self.request.query_params.get('name')
if name is not None:
u_capital = name.capitalize()
u_lower = name.lower()
queryset = queryset.filter(Q(name__contains=u_capital) | Q(name__contains=u_lower))
queryset = queryset.order_by('name')
return queryset
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment