Skip to content

Commit 9eefb20

Browse files
committed
/idtracker/ballot/NNNN/: avoid exception for dangling ballot (with no document)
- Legacy-Id: 2199
1 parent 725f391 commit 9eefb20

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ietf/idtracker/views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
# Create your views here.
4-
from django.http import HttpResponsePermanentRedirect
4+
from django.http import HttpResponsePermanentRedirect, Http404
55
from django.template import RequestContext
66
from django.shortcuts import get_object_or_404, render_to_response
77
from django.views.generic.list_detail import object_detail, object_list
@@ -47,7 +47,10 @@ def redirect_filename(request, filename):
4747

4848
def redirect_ballot(request, object_id):
4949
ballot = get_object_or_404(BallotInfo, pk=object_id)
50-
id = ballot.drafts.filter(primary_flag=1)[0]
50+
ids = ballot.drafts.filter(primary_flag=1)
51+
if len(ids) == 0:
52+
raise Http404("Ballot does not correspond to any document")
53+
id = ids[0]
5154
if id.rfc_flag:
5255
return HttpResponsePermanentRedirect("/doc/rfc"+str(id.draft_id)+"/#ballot")
5356
else:

0 commit comments

Comments
 (0)