Skip to content

Commit

Permalink
fix: Raise 404 when multiple person found in /community/personal/
Browse files Browse the repository at this point in the history
  • Loading branch information
kesara committed Feb 9, 2024
1 parent d42215b commit 051022d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions ietf/community/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ def test_view_list_duplicates(self):

url = urlreverse(ietf.community.views.view_list, kwargs={ "email_or_name": person.plain_name()})
r = self.client.get(url)
self.assertEqual(r.status_code, 300)
self.assertIn("[email protected]", r.content.decode())
self.assertIn("[email protected]", r.content.decode())
self.assertEqual(r.status_code, 404, msg="Found multiple persons")


def complex_person(self, *args, **kwargs):
person = PersonFactory(*args, **kwargs)
Expand Down
16 changes: 8 additions & 8 deletions ietf/community/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def lookup_community_list(request, email_or_name=None, acronym=None):
if hasattr(request.user, 'person') and request.user.person in persons:
person = request.user.person
else:
raise MultiplePersonError("\r\n".join([p.user.username for p in persons]))
raise MultiplePersonError("Found multiple persons")
else:
person = persons[0]
clist = CommunityList.objects.filter(person=person).first() or CommunityList(person=person)
Expand All @@ -54,7 +54,7 @@ def view_list(request, email_or_name=None):
try:
clist = lookup_community_list(request, email_or_name)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))

docs = docs_tracked_by_community_list(clist)
docs, meta = prepare_document_table(request, docs, request.GET)
Expand All @@ -76,7 +76,7 @@ def manage_list(request, email_or_name=None, acronym=None):
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))

if not can_manage_community_list(request.user, clist):
permission_denied(request, "You do not have permission to access this view")
Expand Down Expand Up @@ -166,7 +166,7 @@ def track_document(request, name, email_or_name=None, acronym=None):
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))
if not can_manage_community_list(request.user, clist):
permission_denied(request, "You do not have permission to access this view")

Expand All @@ -191,7 +191,7 @@ def untrack_document(request, name, email_or_name=None, acronym=None):
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))
if not can_manage_community_list(request.user, clist):
permission_denied(request, "You do not have permission to access this view")

Expand All @@ -213,7 +213,7 @@ def export_to_csv(request, email_or_name=None, acronym=None):
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))

response = HttpResponse(content_type='text/csv')

Expand Down Expand Up @@ -257,7 +257,7 @@ def feed(request, email_or_name=None, acronym=None):
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))

significant = request.GET.get('significant', '') == '1'

Expand Down Expand Up @@ -298,7 +298,7 @@ def subscription(request, email_or_name=None, acronym=None):
if clist.pk is None:
raise Http404
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
raise Http404(str(err))

person = request.user.person

Expand Down

0 comments on commit 051022d

Please sign in to comment.