Skip to content

Commit 518a038

Browse files
committed
Import more history (enough for draft-ietf-mboned-ssm232), handle multiple-changes-in-one comments gracefully
- Legacy-Id: 2715
1 parent 2dee1bd commit 518a038

3 files changed

Lines changed: 106 additions & 48 deletions

File tree

redesign/doc/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ class SendQueue(models.Model):
159159
# IESG events
160160
("sent_ballot_announcement", "Sent ballot announcement"),
161161
("deferred_ballot", "Deferred ballot"),
162-
("approved_ballot", "Approved ballot"),
163162
("changed_ballot_position", "Changed ballot position"),
164163
("changed_ballot_approval_text", "Changed ballot approval text"),
165164
("changed_ballot_writeup_text", "Changed ballot writeup text"),
@@ -174,6 +173,7 @@ class SendQueue(models.Model):
174173

175174
("resolved_to_do_not_publish", "Resolved to 'do not publish'"),
176175
("resolved_to_no_problem", "Resolved to 'no problem'"),
176+
("iesg_approved", "IESG approved document"),
177177

178178
("approved_in_minute", "Approved in minute"),
179179
]

redesign/doc/proxy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def b_sent_date(self):
111111
#b_approve_date = models.DateField(null=True, blank=True)
112112
@property
113113
def b_approve_date(self):
114-
e = self.latest_event(type="approved_ballot")
114+
e = self.latest_event(type="iesg_approved")
115115
return e.time if e else None
116116

117117
#wgreturn_date = models.DateField(null=True, blank=True) # unused
@@ -412,18 +412,18 @@ def active(self):
412412
#an_sent = models.BooleanField()
413413
@property
414414
def an_sent(self):
415-
return bool(self.latest_event(type="approved_ballot"))
415+
return bool(self.latest_event(type="iesg_approved"))
416416

417417
#an_sent_date = models.DateField(null=True, blank=True)
418418
@property
419419
def an_sent_date(self):
420-
e = self.latest_event(type="approved_ballot")
420+
e = self.latest_event(type="iesg_approved")
421421
return e.time if e else None
422422

423423
#an_sent_by = models.ForeignKey(IESGLogin, db_column='an_sent_by', related_name='ansent', null=True)
424424
@property
425425
def an_sent_by(self):
426-
e = self.latest_event(type="approved_ballot")
426+
e = self.latest_event(type="iesg_approved")
427427
return e.by if e else None
428428

429429
#defer = models.BooleanField()

redesign/import-document-state.py

Lines changed: 101 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,16 @@ def date_in_match(match):
148148
re_telechat_agenda = re.compile(r"(Placed on|Removed from) agenda for telechat - %s by" % date_re_str)
149149
re_ballot_position = re.compile(r"\[Ballot Position Update\] (New position, (?P<position>.*), has been recorded (|for (?P<for>.*) )|Position (|for (?P<for2>.*) )has been changed to (?P<position2>.*) from .*)by (?P<by>.*)")
150150
re_ballot_issued = re.compile(r"Ballot has been issued by")
151-
re_state_changed = re.compile(r"(State (changed|Changes) to <b>(?P<to>.*)</b> from <b>(?P<from>.*)</b> by|Sub state has been changed to (?P<tosub>.*) from (?P<fromsub>.*))")
152-
re_note_field_cleared = re.compile(r"Note field has been cleared by")
153-
re_draft_added = re.compile(r"Draft [Aa]dded (by .*)? in state (?P<state>.*)")
151+
re_state_changed = re.compile(r"(State (has been changed|changed|Changes) to <b>(?P<to>.*)</b> from <b>(?P<from>.*)</b> by|Sub state has been changed to (?P<tosub>.*) from (?P<fromsub>.*))")
152+
re_note_changed = re.compile(r"(\[Note\]: .*'.*'|Note field has been cleared)")
153+
re_draft_added = re.compile(r"Draft [Aa]dded (by .*)?( in state (?P<state>.*))?")
154154
re_last_call_requested = re.compile(r"Last Call was requested")
155-
re_status_date_changed = re.compile(r"Status [dD]ate has been changed to (<b>)?" + date_re_str)
155+
re_document_approved = re.compile(r"IESG has approved and state has been changed to")
156156

157+
re_status_date_changed = re.compile(r"Status [dD]ate has been changed to (<b>)?" + date_re_str)
158+
re_responsible_ad_changed = re.compile(r"(Responsible AD|Shepherding AD) has been changed to (<b>)?")
159+
re_intended_status_changed = re.compile(r"Intended [sS]tatus has been changed to (<b>)?")
160+
re_state_change_notice = re.compile(r"State Change Notice email list (have been change|has been changed) (<b>)?")
157161

158162
all_drafts = InternetDraft.objects.all().select_related()
159163
if draft_name_to_import:
@@ -192,10 +196,10 @@ def date_in_match(match):
192196
d.internal_comments = o.comments or "" # FIXME: maybe put these somewhere else
193197
d.save()
194198

199+
# clear already imported events
200+
d.event_set.all().delete()
201+
195202
if o.idinternal:
196-
# clear already imported events
197-
d.event_set.all().delete()
198-
199203
# extract events
200204
for c in o.idinternal.documentcomment_set.order_by('date', 'time', 'id'):
201205
handled = False
@@ -210,7 +214,6 @@ def date_in_match(match):
210214
e.returning_item = bool(o.idinternal.returning_item)
211215
save_event(d, e, c)
212216
handled = True
213-
214217

215218
# ballot issued
216219
match = re_ballot_issued.search(c.comment_text)
@@ -233,7 +236,6 @@ def date_in_match(match):
233236
save_event(d, e, c)
234237
handled = True
235238

236-
237239
# ballot positions
238240
match = re_ballot_position.search(c.comment_text)
239241
if match:
@@ -253,7 +255,6 @@ def date_in_match(match):
253255
save_event(d, e, c)
254256
handled = True
255257

256-
257258
# ballot discusses/comments
258259
if c.ballot in (DocumentComment.BALLOT_DISCUSS, DocumentComment.BALLOT_COMMENT):
259260
e = BallotPosition()
@@ -292,42 +293,89 @@ def date_in_match(match):
292293
save_event(d, e, c)
293294
handled = True
294295

295-
# note cleared
296-
match = re_note_field_cleared.search(c.comment_text)
296+
# note changed
297+
match = re_note_changed.search(c.comment_text)
297298
if match:
298299
e = Event(type="changed_document")
299300
save_event(d, e, c)
300301
handled = True
301302

302-
# note cleared
303+
# draft added
303304
match = re_draft_added.search(c.comment_text)
304305
if match:
305306
e = Event(type="changed_document")
306307
save_event(d, e, c)
307308
handled = True
308309

309-
# status date changed
310-
match = re_status_date_changed.search(c.comment_text)
311-
if match:
312-
# FIXME: handle multiple comments in one
313-
e = Status(type="changed_status_date", date=date_in_match(match))
314-
save_event(d, e, c)
315-
handled = True
316-
317310
# new version
318311
if c.comment_text == "New version available":
319312
e = NewRevision(type="new_revision", rev=c.version)
320313
save_event(d, e, c)
321314
handled = True
322315

316+
# approved document
317+
match = re_document_approved.search(c.comment_text)
318+
if match:
319+
e = Event(type="iesg_approved")
320+
save_event(d, e, c)
321+
handled = True
322+
323+
324+
# some changes can be bundled - this is not entirely
325+
# convenient, especially since it makes it hard to give
326+
# each a type, so unbundle them
327+
if not handled:
328+
unhandled_lines = []
329+
for line in c.comment_text.split("<br>"):
330+
# status date changed
331+
match = re_status_date_changed.search(line)
332+
if match:
333+
e = Status(type="changed_status_date", date=date_in_match(match))
334+
e.desc = line
335+
save_event(d, e, c)
336+
handled = True
337+
338+
# AD/job owner changed
339+
match = re_responsible_ad_changed.search(line)
340+
if match:
341+
e = Event(type="changed_draft")
342+
e.desc = line
343+
save_event(d, e, c)
344+
handled = True
345+
346+
# intended standard level changed
347+
match = re_intended_status_changed.search(line)
348+
if match:
349+
e = Event(type="changed_draft")
350+
e.desc = line
351+
save_event(d, e, c)
352+
handled = True
353+
354+
# state change notice
355+
match = re_state_change_notice.search(line)
356+
if match:
357+
e = Event(type="changed_draft")
358+
e.desc = line
359+
save_event(d, e, c)
360+
handled = True
361+
362+
# multiline change bundles end with a single "by xyz" that we skip
363+
if not handled and not line.startswith("by <b>"):
364+
unhandled_lines.append(line)
365+
366+
if handled:
367+
c.comment_text = "<br>".join(unhandled_lines)
368+
369+
323370
# all others are added as comments
324371
if not handled:
325372
e = Event(type="added_comment")
326373
save_event(d, e, c)
327374

328375
# stop typical comments from being output
329376
typical_comments = ["Who is the Document Shepherd for this document",
330-
"We understand that this document doesn't require any IANA actions"]
377+
"We understand that this document doesn't require any IANA actions",
378+
]
331379
for t in typical_comments:
332380
if t in c.comment_text:
333381
handled = True
@@ -336,22 +384,6 @@ def date_in_match(match):
336384
if not handled:
337385
print "couldn't handle %s '%s'" % (c.id, c.comment_text.replace("\n", "").replace("\r", ""))
338386

339-
# import new revision changes from DraftVersions
340-
known_revisions = set(e.newrevision.rev for e in d.event_set.filter(type="new_revision").select_related('newrevision'))
341-
for v in DraftVersions.objects.filter(filename=d.name).order_by("revision"):
342-
if v.revision not in known_revisions:
343-
e = NewRevision(type="new_revision")
344-
e.rev = v.revision
345-
# we don't have time information in this source, so
346-
# hack the seconds to include the revision to ensure
347-
# they're ordered correctly
348-
e.time = datetime.datetime.combine(v.revision_date, datetime.time(0, 0, int(v.revision)))
349-
e.by = system_email
350-
e.doc = d
351-
e.desc = "New version available"
352-
e.save()
353-
known_revisions.add(v.revision)
354-
355387
# import events that might be missing, we don't know where to
356388
# place them but if we don't generate them, we'll be missing
357389
# the information completely
@@ -364,7 +396,33 @@ def date_in_match(match):
364396
e.desc = "Status date has been changed to <b>%s</b> from <b>%s</b>" % (o.idinternal.status_date, status_date)
365397
e.save()
366398

399+
e = d.latest_event(Event, type="iesg_approved")
400+
approved_date = e.time.date() if e else None
401+
if o.b_approve_date != approved_date:
402+
e = Event(type="iesg_approved")
403+
e.time = o.idinternal.b_approve_date
404+
e.by = system_email
405+
e.doc = d
406+
e.desc = "IESG has approved"
407+
e.save()
408+
367409
# FIXME: import writeups
410+
411+
# import missing revision changes from DraftVersions
412+
known_revisions = set(e.newrevision.rev for e in d.event_set.filter(type="new_revision").select_related('newrevision'))
413+
for v in DraftVersions.objects.filter(filename=d.name).order_by("revision"):
414+
if v.revision not in known_revisions:
415+
e = NewRevision(type="new_revision")
416+
e.rev = v.revision
417+
# we don't have time information in this source, so
418+
# hack the seconds to include the revision to ensure
419+
# they're ordered correctly
420+
e.time = datetime.datetime.combine(v.revision_date, datetime.time(0, 0, int(v.revision)))
421+
e.by = system_email
422+
e.doc = d
423+
e.desc = "New version available"
424+
e.save()
425+
known_revisions.add(v.revision)
368426

369427
print "imported", d.name, "S:", d.iesg_state
370428

@@ -397,7 +455,7 @@ class CheckListInternetDraft(models.Model):
397455
lc_expiration_date = models.DateField(null=True, blank=True)
398456
b_sent_date = models.DateField(null=True, blank=True)
399457
b_discussion_date = models.DateField(null=True, blank=True)
400-
b_approve_date = models.DateField(null=True, blank=True)
458+
# b_approve_date = models.DateField(null=True, blank=True)
401459
wgreturn_date = models.DateField(null=True, blank=True)
402460
rfc_number = models.IntegerField(null=True, blank=True, db_index=True)
403461
# comments = models.TextField(blank=True,null=True)
@@ -426,7 +484,7 @@ class CheckListIDInternal(models.Model):
426484
mark_by = models.ForeignKey('IESGLogin', db_column='mark_by', related_name='marked')
427485
# job_owner = models.ForeignKey(IESGLogin, db_column='job_owner', related_name='documents')
428486
event_date = models.DateField(null=True)
429-
area_acronym = models.ForeignKey('Area')
487+
# area_acronym = models.ForeignKey('Area')
430488
cur_sub_state = BrokenForeignKey('IDSubState', related_name='docs', null=True, blank=True, null_values=(0, -1))
431489
prev_sub_state = BrokenForeignKey('IDSubState', related_name='docs_prev', null=True, blank=True, null_values=(0, -1))
432490
# returning_item = models.IntegerField(null=True, blank=True)
@@ -442,9 +500,9 @@ class CheckListIDInternal(models.Model):
442500
class CheckListBallotInfo(models.Model):
443501
ballot = models.AutoField(primary_key=True, db_column='ballot_id')
444502
active = models.BooleanField()
445-
an_sent = models.BooleanField()
446-
an_sent_date = models.DateField(null=True, blank=True)
447-
an_sent_by = models.ForeignKey('IESGLogin', db_column='an_sent_by', related_name='ansent', null=True)
503+
# an_sent = models.BooleanField()
504+
# an_sent_date = models.DateField(null=True, blank=True)
505+
# an_sent_by = models.ForeignKey('IESGLogin', db_column='an_sent_by', related_name='ansent', null=True)
448506
defer = models.BooleanField(blank=True)
449507
defer_by = models.ForeignKey('IESGLogin', db_column='defer_by', related_name='deferred', null=True)
450508
defer_date = models.DateField(null=True, blank=True)

0 commit comments

Comments
 (0)