Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Raise 404 when multiple person found in /community/personal/ #7038

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)


def complex_person(self, *args, **kwargs):
person = PersonFactory(*args, **kwargs)
Expand Down
30 changes: 15 additions & 15 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 @@ -53,8 +53,8 @@ def lookup_community_list(request, email_or_name=None, acronym=None):
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)
except MultiplePersonError:
raise Http404

docs = docs_tracked_by_community_list(clist)
docs, meta = prepare_document_table(request, docs, request.GET)
Expand All @@ -75,8 +75,8 @@ def manage_list(request, email_or_name=None, acronym=None):
# database so we can't call related stuff on it yet
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
except MultiplePersonError:
raise Http404

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 @@ -165,8 +165,8 @@ def track_document(request, name, email_or_name=None, acronym=None):
if request.method == "POST":
try:
clist = lookup_community_list(request, email_or_name, acronym)
except MultiplePersonError as err:
return HttpResponse(str(err), status=300)
except MultiplePersonError:
raise Http404
if not can_manage_community_list(request.user, clist):
permission_denied(request, "You do not have permission to access this view")

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

Expand All @@ -212,8 +212,8 @@ def untrack_document(request, name, email_or_name=None, acronym=None):
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)
except MultiplePersonError:
raise Http404

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

Expand Down Expand Up @@ -256,8 +256,8 @@ def export_to_csv(request, email_or_name=None, acronym=None):
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)
except MultiplePersonError:
raise Http404

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

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

person = request.user.person

Expand Down
Loading