Skip to content

Commit

Permalink
made pennkeys lowercase and changed test case
Browse files Browse the repository at this point in the history
  • Loading branch information
nruia-penn committed Oct 24, 2024
1 parent 00501b3 commit 2b50939
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions backend/courses/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/courses/test_friendship_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2b50939

Please sign in to comment.