Skip to content

Commit b3bdbc9

Browse files
committed
refactored close_open_ballots, creating a way to close one abllot at a time. rewrote the clear ballot code to close each open ballot and open a new one
- Legacy-Id: 4885
1 parent 27186d1 commit b3bdbc9

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

ietf/doc/utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,23 @@ def needed_ballot_positions(doc, active_positions):
7474

7575
return " ".join(answer)
7676

77-
def create_ballot_if_not_open(doc, by, ballot_type_slug):
78-
if not doc.ballot_open(ballot_type_slug):
77+
def create_ballot_if_not_open(doc, by, ballot_slug):
78+
if not doc.ballot_open(ballot_slug):
7979
e = BallotDocEvent(type="created_ballot", by=by, doc=doc)
80-
e.ballot_type = BallotType.objects.get(doc_type=doc.type, slug=ballot_type_slug)
80+
e.ballot_type = BallotType.objects.get(doc_type=doc.type, slug=ballot_slug)
8181
e.desc = u'Created "%s" ballot' % e.ballot_type.name
8282
e.save()
8383

84+
def close_ballot(doc, by, ballot_slug):
85+
if doc.ballot_open(ballot_slug):
86+
e = BallotDocEvent(type="closed_ballot", doc=doc, by=by)
87+
e.ballot_type = BallotType.objects.get(doc_type=doc.type,slug=ballot_slug)
88+
e.desc = 'Closed "%s" ballot' % e.ballot_type.name
89+
e.save()
90+
8491
def close_open_ballots(doc, by):
8592
for t in BallotType.objects.filter(doc_type=doc.type_id):
86-
if doc.ballot_open(t.slug):
87-
e = BallotDocEvent(type="closed_ballot", doc=doc, by=by)
88-
e.ballot_type = t
89-
e.desc = 'Closed "%s" ballot' % t.name
90-
e.save()
93+
close_ballot(doc, by, t.slug )
9194

9295
def augment_with_start_time(docs):
9396
"""Add a started_time attribute to each document with the time of

ietf/idrfc/views_ballot.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,15 +385,13 @@ def send_ballot_commentREDESIGN(request, name, ballot_id):
385385

386386
@group_required('Secretariat')
387387
def clear_ballot(request, name):
388-
"""Clear all positions and discusses. This is actually accomplished by creating a new
389-
started_iesg_process DocEvent."""
388+
"""Clear all positions and discusses on every open ballot for a document."""
390389
doc = get_object_or_404(Document, name=name)
391390
if request.method == 'POST':
392-
DocEvent.objects.create(type='started_iesg_process',
393-
doc=doc,
394-
by=request.user.get_profile(),
395-
desc='cleared_ballot')
396-
391+
by = request.user.get_profile()
392+
for t in BallotType.objects.filter(doc_type=doc.type_id):
393+
close_ballot(doc, by, t.slug)
394+
create_ballot_if_not_open(doc, by, t.slug)
397395
return HttpResponseRedirect(urlreverse("doc_view", kwargs=dict(name=doc.name)))
398396

399397
return render_to_response('idrfc/clear_ballot.html',

0 commit comments

Comments
 (0)