Skip to content

Commit

Permalink
Fix issue where deferring a ballot causes 500 error in Telechat app. F…
Browse files Browse the repository at this point in the history
…ixes #1342.  Commit ready for merge.

 - Legacy-Id: 13336
  • Loading branch information
rpcross committed May 12, 2017
1 parent a6070f8 commit 7542e8d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ietf/secr/telechat/tests.py
Expand Up @@ -53,6 +53,16 @@ def test_doc_detail_draft(self):
self.assertEqual(q("#telechat-positions-table").find("th:contains('Recuse')").length,1)
self.assertEqual(q("#telechat-positions-table").find("th:contains('No Record')").length,1)

def test_doc_detail_draft_invalid(self):
'''Test using a document not on telechat agenda'''
draft = make_test_data()
date = get_next_telechat_date().strftime('%Y-%m-%d')
url = reverse('ietf.secr.telechat.views.doc_detail', kwargs={'date':date, 'name':draft.name})
self.client.login(username="secretary", password="secretary+password")
response = self.client.get(url, follow=True)
self.assertRedirects(response, reverse('ietf.secr.telechat.views.doc', kwargs={'date':date}))
self.assertTrue('not on the Telechat agenda' in response.content)

def test_doc_detail_charter(self):
make_test_data()
by=Person.objects.get(name="(System)")
Expand Down
14 changes: 14 additions & 0 deletions ietf/secr/telechat/views.py
Expand Up @@ -124,6 +124,15 @@ def get_first_doc(agenda):

return None

def is_doc_on_telechat(doc,date):
'''Returns true if the document is on the Telechat agenda for date=date.
Where date is a string in the format YYYY-MM-DD
'''
if doc.telechat_date() and doc.telechat_date().strftime("%Y-%m-%d") == date:
return True
else:
return False

# -------------------------------------------------
# View Functions
# -------------------------------------------------
Expand Down Expand Up @@ -162,6 +171,11 @@ def doc_detail(request, date, name):
changes to ballot positions and document state.
'''
doc = get_object_or_404(Document, docalias__name=name)
if not is_doc_on_telechat(doc, date):
messages.warning(request, 'Dcoument: {name} is not on the Telechat agenda for {date}'.format(
name=doc.name,
date=date))
return redirect('ietf.secr.telechat.views.doc', date=date)

# As of Datatracker v4.32, Conflict Review (conflrev) Document Types can
# be added to the Telechat agenda. If Document.type_id == draft use draft-iesg
Expand Down

0 comments on commit 7542e8d

Please sign in to comment.