Skip to content

Commit 198c003

Browse files
committed
Merged in [15084] from rjsparks@nostrum.com:
Corrected the implementation of clear_ballot. Added a test for it. Restored functionality to ballot popups that was missing because a template variable was not passed in. - Legacy-Id: 15092 Note: SVN reference [15084] has been migrated to Git commit ee346ed
2 parents d994a58 + ee346ed commit 198c003

8 files changed

Lines changed: 29 additions & 10 deletions

File tree

ietf/doc/tests_ballot.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,23 @@ def test_disapprove_ballot(self):
644644
self.assertEqual(len(outbox), mailbox_before + 1)
645645
self.assertTrue("NOT be published" in str(outbox[-1]))
646646

647+
def test_clear_ballot(self):
648+
draft = make_test_data()
649+
ad = Person.objects.get(user__username="ad")
650+
ballot = create_ballot_if_not_open(None, draft, ad, 'approve')
651+
old_ballot_id = ballot.id
652+
draft.set_state(State.objects.get(used=True, type="draft-iesg", slug="iesg-eva"))
653+
url = urlreverse('ietf.doc.views_ballot.clear_ballot', kwargs=dict(name=draft.name,ballot_type_slug=draft.ballot_open('approve').ballot_type.slug))
654+
login_testing_unauthorized(self, "secretary", url)
655+
r = self.client.get(url)
656+
self.assertEqual(r.status_code, 200)
657+
r = self.client.post(url,{})
658+
self.assertEqual(r.status_code, 302)
659+
ballot = draft.ballot_open('approve')
660+
self.assertIsNotNone(ballot)
661+
self.assertEqual(ballot.ballotpositiondocevent_set.count(),0)
662+
self.assertNotEqual(old_ballot_id, ballot.id)
663+
647664
class MakeLastCallTests(TestCase):
648665
def test_make_last_call(self):
649666
draft = make_test_data()

ietf/doc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
url(r'^%(name)s/edit/adopt/$' % settings.URL_REGEXPS, views_draft.adopt_draft),
109109
url(r'^%(name)s/edit/state/(?P<state_type>draft-stream-[a-z]+)/$' % settings.URL_REGEXPS, views_draft.change_stream_state),
110110

111-
url(r'^%(name)s/edit/clearballot/$' % settings.URL_REGEXPS, views_ballot.clear_ballot),
111+
url(r'^%(name)s/edit/clearballot/(?P<ballot_type_slug>[\w-]+)/$' % settings.URL_REGEXPS, views_ballot.clear_ballot),
112112
url(r'^%(name)s/edit/deferballot/$' % settings.URL_REGEXPS, views_ballot.defer_ballot),
113113
url(r'^%(name)s/edit/undeferballot/$' % settings.URL_REGEXPS, views_ballot.undefer_ballot),
114114
url(r'^%(name)s/edit/lastcalltext/$' % settings.URL_REGEXPS, views_ballot.lastcalltext),

ietf/doc/views_ballot.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import debug # pyflakes:ignore
1717

1818
from ietf.doc.models import ( Document, State, DocEvent, BallotDocEvent, BallotPositionDocEvent,
19-
BallotType, LastCallDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS )
19+
LastCallDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS )
2020
from ietf.doc.utils import ( add_state_change_event, close_ballot, close_open_ballots,
2121
create_ballot_if_not_open, update_telechat )
2222
from ietf.doc.mails import ( email_ballot_deferred, email_ballot_undeferred,
@@ -381,14 +381,13 @@ def send_ballot_comment(request, name, ballot_id):
381381
))
382382

383383
@role_required('Area Director','Secretariat')
384-
def clear_ballot(request, name):
384+
def clear_ballot(request, name, ballot_type_slug):
385385
"""Clear all positions and discusses on every open ballot for a document."""
386386
doc = get_object_or_404(Document, name=name)
387387
if request.method == 'POST':
388388
by = request.user.person
389-
for t in BallotType.objects.filter(doc_type=doc.type_id):
390-
close_ballot(doc, by, t.slug)
391-
create_ballot_if_not_open(request, doc, by, t.slug)
389+
if close_ballot(doc, by, ballot_type_slug):
390+
create_ballot_if_not_open(request, doc, by, ballot_type_slug)
392391
if doc.get_state('draft-iesg').slug == 'defer':
393392
do_undefer_ballot(request,doc)
394393
return redirect("ietf.doc.views_doc.document_main", name=doc.name)

ietf/doc/views_doc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,13 @@ def document_ballot(request, name, ballot_id=None):
965965
def ballot_popup(request, name, ballot_id):
966966
doc = get_object_or_404(Document, docalias__name=name)
967967
c = document_ballot_content(request, doc, ballot_id=ballot_id, editable=False)
968+
ballot = get_object_or_404(BallotDocEvent,id=ballot_id)
968969
return render(request, "doc/ballot_popup.html",
969970
dict(doc=doc,
970971
ballot_content=c,
971972
ballot_id=ballot_id,
973+
ballot_type_slug=ballot.ballot_type.slug,
974+
editable=True,
972975
))
973976

974977

ietf/nomcom/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def make_nomineeposition_for_newperson(nomcom, candidate_name, candidate_email,
375375
email = Email.objects.create(address=candidate_email)
376376
person = Person.objects.create(name=candidate_name,
377377
ascii=unidecode_name(candidate_name),
378-
address=candidate_email)
378+
)
379379
email.person = person
380380
email.save()
381381

ietf/templates/doc/ballot_popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h4 class="modal-title" id="modal-title-{{ ballot_id }}">Ballot for {{ doc.name
3838
{% endif %}
3939

4040
{% if user|has_role:"Secretariat" %}
41-
<a class="btn btn-danger" href="{% url 'ietf.doc.views_ballot.clear_ballot' name=doc.name %}">Clear ballot</a>
41+
<a class="btn btn-danger" href="{% url 'ietf.doc.views_ballot.clear_ballot' name=doc.name ballot_type_slug=ballot_type_slug %}">Clear ballot</a>
4242
{% endif %}
4343
{% endif %}
4444
{% endif %}

ietf/templates/doc/document_ballot_content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h4><span class="label label-{{ n|pos_to_label }}"> {{ n.name }}</span></h4>
6767
{% endif %}
6868

6969
{% if user|has_role:"Area Director,Secretariat" %}
70-
<a class="btn btn-danger" href="{% url 'ietf.doc.views_ballot.clear_ballot' name=doc.name %}">Clear ballot</a>
70+
<a class="btn btn-danger" href="{% url 'ietf.doc.views_ballot.clear_ballot' name=doc.name ballot_type_slug=ballot.ballot_type.slug%}">Clear ballot</a>
7171
{% endif %}
7272
{% endif %}
7373
{% endif %}

ietf/utils/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def make_immutable_base_data():
6060
date4 = TelechatDate.objects.create(date=t + datetime.timedelta(days=14 * 3)).date # pyflakes:ignore
6161

6262
# system
63-
system_person = Person.objects.create(name="(System)", ascii="(System)", address="")
63+
system_person = Person.objects.create(name="(System)", ascii="(System)")
6464
Email.objects.create(address="", person=system_person)
6565

6666
# high-level groups

0 commit comments

Comments
 (0)