File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,25 @@ def get_user_id_from_token(self, request):
33
33
def list (self , request ):
34
34
try :
35
35
username = self .get_user_id_from_token (request )
36
+ User = get_user_model ()
37
+ users = [{"user_id" : str (x .user_id ), "first_name" : x .first_name } for x in User .objects .all ()]
38
+
39
+ filtered_users = []
40
+
41
+ for user in users :
42
+ if user ["user_id" ] != username :
43
+ filtered_users .append (user )
44
+
36
45
piggies = Piggies .objects .filter (username = username )
37
46
serializer = PiggiesSerializer (piggies , many = True )
38
- return Response (data = serializer .data )
47
+ final_users = []
48
+
49
+ for pig in serializer .data :
50
+ for user in filtered_users :
51
+ if str (pig ["piggy" ]) == user ["user_id" ]:
52
+ final_users .append (user )
53
+
54
+ return Response (data = final_users )
39
55
except Piggies .DoesNotExist :
40
56
return Response ({"error" : "Piggies not found" }, status = status .HTTP_404_NOT_FOUND )
41
57
except Exception as e :
You can’t perform that action at this time.
0 commit comments