diff --git a/backend/courses/views.py b/backend/courses/views.py index 20cc5053..d8504f7b 100644 --- a/backend/courses/views.py +++ b/backend/courses/views.py @@ -520,7 +520,8 @@ def get_all_friendships(self): def post(self, request): sender = request.user - recipient = get_object_or_404(User, username=request.data.get("pennkey")) + + recipient = get_object_or_404(User, username=request.data.get("pennkey").lower()) existing_friendship = ( self.get_all_friendships().filter(Q(recipient=recipient) | Q(sender=recipient)).first() @@ -556,7 +557,7 @@ def delete(self, request): # (depends on who sends the request) res = {} sender = request.user - recipient = get_object_or_404(User, username=request.data.get("pennkey")) + recipient = get_object_or_404(User, username=request.data.get("pennkey").lower()) existing_friendship = ( self.get_all_friendships().filter(Q(recipient=recipient) | Q(sender=recipient)).first() diff --git a/backend/tests/courses/test_friendship_models.py b/backend/tests/courses/test_friendship_models.py index 8eae9d8a..6c89c7d0 100644 --- a/backend/tests/courses/test_friendship_models.py +++ b/backend/tests/courses/test_friendship_models.py @@ -27,7 +27,7 @@ def test_basic_friendship(self): self.assertTrue(UserProfile.objects.filter(user=u2).exists()) self.assertTrue(UserProfile.objects.filter(user=u1).exists()) - make_friends = self.client1.post(reverse("friendship"), {"pennkey": u2.username}) + make_friends = self.client1.post(reverse("friendship"), {"pennkey": u2.username.upper()}) self.assertEquals(make_friends.status_code, 201) self.assertTrue(