Skip to content

Commit 8493ce7

Browse files
committed
Merged [4885] from rjsparks@nostrum.com:
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: 4960 Note: SVN reference [4885] has been migrated to Git commit b3bdbc9
3 parents 22b822e + b3bdbc9 + 8a4f5e0 commit 8493ce7

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

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',

test/mergedevbranch

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ else
124124
die "Could not find a branch matching '$branch'"
125125
fi
126126

127-
if grep "@rev $branch" mergelog; then die "Changeset $branch@rev is already in the merge log"; fi
127+
if grep "@$rev $branch" mergelog; then die "Changeset $branch@$rev is already in the merge log"; fi
128128

129129
note "Will attempt merge from $branch@$rev"
130130

@@ -135,12 +135,11 @@ who=$2; echo -e "\n$who"
135135
comment=$(echo "$info" | tail -n +3); echo -e "$comment\n"
136136
files=$(svn diff ${repo}/ -c $rev --summarize | awk '{$1=""; print;}' | while read file; do echo "${file/$repo\/$branch\//}"; done)
137137
138-
echo -n "Files: \n$files"
138+
echo -e "Files: \n$files"
139139
140140
note "Writing commit script"
141-
echo -e "#!/bin/bash\n\nsvn commit -m \"Merged [$rev] from $who: ${comment/\"/\'} ${fix/\"/\'}\" && rm $0" > ../commit-${rev}-merge.sh
142-
chmod +x ../commit-${rev}-merge.sh
143-
cp ../commit-${rev}-merge.sh ./commit
141+
echo -e "#!/bin/bash\n\nsvn commit -m \"Merged [$rev] from $who: ${comment/\"/\'} ${fix/\"/\'}\"" > ../cicmd/commit-${rev}-merge.sh
142+
chmod +x ../cicmd/commit-${rev}-merge.sh
144143
145144
note "Do the merge:"
146145
svn merge -c $rev ${repo}/$branch . || die "Merge of $branch @$rev failed. The merge command was:
@@ -155,14 +154,11 @@ date +"%Y-%m-%d %H:%M:%S $G$C$M @$rev $branch" >> mergelog
155154
156155
cd ../
157156
rsync -a $cwd/ merged@$rev/
158-
cd merged@$rev/
159-
cp ../commit-${rev}-merge.sh commit
160-
note "Now in $PWD"
161-
162-
note "Running tests..."
163-
{ PYTHONPATH=$PWD ietf/manage.py test || die "Testing of $branch@$rev merged to trunk failed -- not sending email, not committing."; } 2>&1 | tee testlog
157+
cp cicmd/commit-${rev}-merge.sh merged@$rev/commit
158+
cd -
164159
165160
note "Sending email to changeset author: <$who>"
161+
166162
mail -s "Merged datatracker branch personal/$branch@$rev to trunk" $who -c henrik@levkowetz.com <<-EOF
167163
Hi,
168164
@@ -183,7 +179,7 @@ if [ "$ARG_COMMIT" ]; then
183179
svn commit -m "Merged [$rev] from $who: $comment $fix"
184180
else
185181
echo "This merge has not been committed yet."
186-
echo "To commit it, run this commit command: ../commit-$rev-merge.sh"
182+
echo "To commit it, run this commit command: ../cicmd/commit-$rev-merge.sh"
187183
fi
188184
189185

0 commit comments

Comments
 (0)