Skip to content

Commit ec3e247

Browse files
committed
Merged in [8262] and [8263] from rjsparks@nostrum.com:
Changes when returning_item is automatically set to match the current IESGs preferences. Removes several chunks of dead code related to editing telechat dates. Improves returning item tests. Refactored multiple edit_telechat functions into one function in doc_views. Added a helper function for determining if ballots have changed to isolate the implementation. Fixed the issue with update_agenda setting the returning item bit even when the user explicitly said not to. Added prompting to encourage proper setting of the returning item bit to the edit_telechat view. Fixes ietf-tools#1209 - Legacy-Id: 8369 Note: SVN reference [8262] has been migrated to Git commit 9d8d0d6 Note: SVN reference [8263] has been migrated to Git commit 35a7436
1 parent d9787d8 commit ec3e247

18 files changed

+157
-201
lines changed

ietf/doc/tests_ballot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def helper_test_defer(self,name):
475475
self.assertEqual(r.status_code, 302)
476476
doc = Document.objects.get(name=name)
477477
self.assertEqual(doc.telechat_date(), second_date)
478-
self.assertTrue(doc.returning_item())
478+
self.assertFalse(doc.returning_item())
479479
defer_states = dict(draft=['draft-iesg','defer'],conflrev=['conflrev','defer'],statchg=['statchg','defer'])
480480
if doc.type_id in defer_states:
481481
self.assertEqual(doc.get_state(defer_states[doc.type_id][0]).slug,defer_states[doc.type_id][1])

ietf/doc/tests_charter.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,35 @@ def test_edit_telechat_date(self):
138138
charter = Document.objects.get(name=charter.name)
139139
self.assertTrue(not charter.latest_event(TelechatDocEvent, "scheduled_for_telechat").telechat_date)
140140

141+
def test_no_returning_item_for_different_ballot(self):
142+
make_test_data()
143+
144+
group = Group.objects.get(acronym="ames")
145+
charter = group.charter
146+
url = urlreverse('charter_telechat_date', kwargs=dict(name=charter.name))
147+
login_testing_unauthorized(self, "secretary", url)
148+
login = Person.objects.get(user__username="secretary")
149+
150+
# Make it so that the charter has been through internal review, and passed its external review
151+
# ballot on a previous telechat
152+
last_week = datetime.date.today()-datetime.timedelta(days=7)
153+
BallotDocEvent.objects.create(type='created_ballot',by=login,doc=charter,
154+
ballot_type=BallotType.objects.get(doc_type=charter.type,slug='r-extrev'),
155+
time=last_week)
156+
TelechatDocEvent.objects.create(type='scheduled_for_telechat',doc=charter,by=login,telechat_date=last_week,returning_item=False)
157+
BallotDocEvent.objects.create(type='created_ballot',by=login,doc=charter,
158+
ballot_type=BallotType.objects.get(doc_type=charter.type,slug='approve'))
159+
160+
# Put the charter onto a future telechat and verify returning item is not set
161+
telechat_date = TelechatDate.objects.active()[1].date
162+
r = self.client.post(url, dict(name=group.name, acronym=group.acronym, telechat_date=telechat_date.isoformat()))
163+
self.assertEqual(r.status_code, 302)
164+
165+
charter = Document.objects.get(name=charter.name)
166+
telechat_event = charter.latest_event(TelechatDocEvent, "scheduled_for_telechat")
167+
self.assertEqual(telechat_event.telechat_date, telechat_date)
168+
self.assertFalse(telechat_event.returning_item)
169+
141170
def test_edit_notify(self):
142171
make_test_data()
143172

ietf/doc/tests_conflict_review.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,11 @@ def test_edit_telechat_date(self):
224224
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
225225
self.assertEqual(doc.latest_event(TelechatDocEvent, "scheduled_for_telechat").telechat_date,telechat_date)
226226

227-
# move it forward a telechat (this should set the returning item bit)
227+
# move it forward a telechat (this should NOT set the returning item bit)
228228
telechat_date = TelechatDate.objects.active().order_by('date')[1].date
229229
r = self.client.post(url,dict(telechat_date=telechat_date.isoformat()))
230230
self.assertEqual(r.status_code,302)
231231
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
232-
self.assertTrue(doc.returning_item())
233-
234-
# clear the returning item bit
235-
r = self.client.post(url,dict(telechat_date=telechat_date.isoformat()))
236-
self.assertEqual(r.status_code,302)
237-
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
238232
self.assertFalse(doc.returning_item())
239233

240234
# set the returning item bit without changing the date
@@ -243,6 +237,12 @@ def test_edit_telechat_date(self):
243237
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
244238
self.assertTrue(doc.returning_item())
245239

240+
# clear the returning item bit
241+
r = self.client.post(url,dict(telechat_date=telechat_date.isoformat()))
242+
self.assertEqual(r.status_code,302)
243+
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
244+
self.assertFalse(doc.returning_item())
245+
246246
# Take the doc back off any telechat
247247
r = self.client.post(url,dict(telechat_date=""))
248248
self.assertEqual(r.status_code, 302)

ietf/doc/tests_draft.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import debug # pyflakes:ignore
1111

1212
from ietf.doc.models import ( Document, DocAlias, DocReminder, DocumentAuthor, DocEvent,
13-
ConsensusDocEvent, LastCallDocEvent, RelatedDocument, State, TelechatDocEvent, WriteupDocEvent )
13+
ConsensusDocEvent, LastCallDocEvent, RelatedDocument, State, TelechatDocEvent,
14+
WriteupDocEvent, BallotDocEvent)
1415
from ietf.doc.utils import get_tags_for_stream_id
1516
from ietf.name.models import StreamName, IntendedStdLevelName, DocTagName
1617
from ietf.group.models import Group
@@ -255,7 +256,25 @@ def test_edit_telechat_date(self):
255256
self.assertEqual(r.status_code, 302)
256257

257258
draft = Document.objects.get(name=draft.name)
258-
self.assertEqual(draft.latest_event(TelechatDocEvent, type="scheduled_for_telechat").telechat_date, TelechatDate.objects.active()[1].date)
259+
telechat_event = draft.latest_event(TelechatDocEvent, type="scheduled_for_telechat")
260+
self.assertEqual(telechat_event.telechat_date, TelechatDate.objects.active()[1].date)
261+
self.assertFalse(telechat_event.returning_item)
262+
263+
# change to a telechat that should cause returning item to be auto-detected
264+
# First, make it appear that the previous telechat has already passed
265+
telechat_event.telechat_date = datetime.date.today()-datetime.timedelta(days=7)
266+
telechat_event.save()
267+
ballot = draft.latest_event(BallotDocEvent, type="created_ballot")
268+
ballot.time = telechat_event.telechat_date
269+
ballot.save()
270+
271+
r = self.client.post(url, data)
272+
self.assertEqual(r.status_code, 302)
273+
274+
draft = Document.objects.get(name=draft.name)
275+
telechat_event = draft.latest_event(TelechatDocEvent, type="scheduled_for_telechat")
276+
self.assertEqual(telechat_event.telechat_date, TelechatDate.objects.active()[1].date)
277+
self.assertTrue(telechat_event.returning_item)
259278

260279
# remove from agenda
261280
data["telechat_date"] = ""

ietf/doc/tests_status_change.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,11 @@ def test_edit_telechat_date(self):
204204
doc = Document.objects.get(name='status-change-imaginary-mid-review')
205205
self.assertEqual(doc.latest_event(TelechatDocEvent, "scheduled_for_telechat").telechat_date,telechat_date)
206206

207-
# move it forward a telechat (this should set the returning item bit)
207+
# move it forward a telechat (this should NOT set the returning item bit)
208208
telechat_date = TelechatDate.objects.active().order_by('date')[1].date
209209
r = self.client.post(url,dict(telechat_date=telechat_date.isoformat()))
210210
self.assertEqual(r.status_code,302)
211211
doc = Document.objects.get(name='status-change-imaginary-mid-review')
212-
self.assertTrue(doc.returning_item())
213-
214-
# clear the returning item bit
215-
r = self.client.post(url,dict(telechat_date=telechat_date.isoformat()))
216-
self.assertEqual(r.status_code,302)
217-
doc = Document.objects.get(name='status-change-imaginary-mid-review')
218212
self.assertFalse(doc.returning_item())
219213

220214
# set the returning item bit without changing the date
@@ -223,6 +217,12 @@ def test_edit_telechat_date(self):
223217
doc = Document.objects.get(name='status-change-imaginary-mid-review')
224218
self.assertTrue(doc.returning_item())
225219

220+
# clear the returning item bit
221+
r = self.client.post(url,dict(telechat_date=telechat_date.isoformat()))
222+
self.assertEqual(r.status_code,302)
223+
doc = Document.objects.get(name='status-change-imaginary-mid-review')
224+
self.assertFalse(doc.returning_item())
225+
226226
# Take the doc back off any telechat
227227
r = self.client.post(url,dict(telechat_date=""))
228228
self.assertEqual(r.status_code, 302)

ietf/doc/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/replaces/$', views_draft.replaces, name='doc_change_replaces'),
7777
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/notify/$', views_draft.edit_notices, name='doc_change_notify'),
7878
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/status/$', views_draft.change_intention, name='doc_change_intended_status'),
79-
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/telechat/$', views_draft.telechat_date, name='doc_change_telechat_date'),
79+
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/telechat/$', views_doc.telechat_date, name='doc_change_telechat_date'),
8080
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/iesgnote/$', views_draft.edit_iesg_note, name='doc_change_iesg_note'),
8181
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/ad/$', views_draft.edit_ad, name='doc_change_ad'),
8282
url(r'^(?P<name>[A-Za-z0-9._+-]+)/edit/consensus/$', views_draft.edit_consensus, name='doc_edit_consensus'),

ietf/doc/urls_charter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
urlpatterns = patterns('',
66
url(r'^state/$', "ietf.doc.views_charter.change_state", name='charter_change_state'),
77
url(r'^(?P<option>initcharter|recharter|abandon)/$', "ietf.doc.views_charter.change_state", name='charter_startstop_process'),
8-
url(r'^telechat/$', "ietf.doc.views_charter.telechat_date", name='charter_telechat_date'),
8+
url(r'^telechat/$', "ietf.doc.views_doc.telechat_date", name='charter_telechat_date'),
99
url(r'^notify/$', "ietf.doc.views_charter.edit_notify", name='charter_edit_notify'),
1010
url(r'^ad/$', "ietf.doc.views_charter.edit_ad", name='charter_edit_ad'),
1111
url(r'^(?P<ann>action|review)/$', "ietf.doc.views_charter.announcement_text", name="charter_edit_announcement"),

ietf/doc/urls_conflict_review.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
url(r'^ad/$', "edit_ad", name='conflict_review_ad'),
88
url(r'^approve/$', "approve", name='conflict_review_approve'),
99
url(r'^start_conflict_review/$', "start_review", name='conflict_review_start'),
10+
)
11+
12+
urlpatterns += patterns('ietf.doc.views_doc',
1013
url(r'^telechat/$', "telechat_date", name='conflict_review_telechat_date'),
1114
)
1215

16+

ietf/doc/urls_status_change.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
url(r'^ad/$', "edit_ad", name='status_change_ad'),
88
url(r'^title/$', "edit_title", name='status_change_title'),
99
url(r'^approve/$', "approve", name='status_change_approve'),
10-
url(r'^telechat/$', "telechat_date", name='status_change_telechat_date'),
1110
url(r'^relations/$', "edit_relations", name='status_change_relations'),
1211
url(r'^last-call/$', "last_call", name='status_change_last_call'),
1312
)
1413

14+
urlpatterns += patterns('ietf.doc.views_doc',
15+
url(r'^telechat/$', "telechat_date", name='status_change_telechat_date'),
16+
)
17+
18+

ietf/doc/utils.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import urllib
44
import math
5+
import datetime
56

67
from django.conf import settings
78
from django.db.models.query import EmptyQuerySet
@@ -306,6 +307,14 @@ def nice_consensus(consensus):
306307
}
307308
return mapping[consensus]
308309

310+
def has_same_ballot(doc, date1, date2=datetime.date.today()):
311+
""" Test if the most recent ballot created before the end of date1
312+
is the same as the most recent ballot created before the
313+
end of date 2. """
314+
ballot1 = doc.latest_event(BallotDocEvent,type='created_ballot',time__lt=date1+datetime.timedelta(days=1))
315+
ballot2 = doc.latest_event(BallotDocEvent,type='created_ballot',time__lt=date2+datetime.timedelta(days=1))
316+
return ballot1==ballot2
317+
309318
def update_telechat(request, doc, by, new_telechat_date, new_returning_item=None):
310319
from ietf.doc.models import TelechatDocEvent
311320

@@ -315,8 +324,6 @@ def update_telechat(request, doc, by, new_telechat_date, new_returning_item=None
315324
prev_returning = bool(prev and prev.returning_item)
316325
prev_telechat = prev.telechat_date if prev else None
317326
prev_agenda = bool(prev_telechat)
318-
319-
returning_item_changed = bool(new_returning_item != None and new_returning_item != prev_returning)
320327

321328
if new_returning_item == None:
322329
returning = prev_returning
@@ -327,9 +334,14 @@ def update_telechat(request, doc, by, new_telechat_date, new_returning_item=None
327334
# fully updated, nothing to do
328335
return
329336

330-
# auto-update returning item
331-
if (not returning_item_changed and on_agenda and prev_agenda
332-
and new_telechat_date != prev_telechat):
337+
# auto-set returning item _ONLY_ if the caller did not provide a value
338+
if ( new_returning_item != None
339+
and on_agenda
340+
and prev_agenda
341+
and new_telechat_date != prev_telechat
342+
and prev_telechat < datetime.date.today()
343+
and has_same_ballot(doc,prev.telechat_date)
344+
):
333345
returning = True
334346

335347
e = TelechatDocEvent()

0 commit comments

Comments
 (0)