@@ -46,6 +46,8 @@ def name(name_class, slug, name, desc=""):
4646type_draft = name (DocTypeName , "draft" , "Draft" )
4747stream_ietf = name (DocStreamName , "ietf" , "IETF" )
4848
49+ relationship_replaces = name (DocRelationshipName , "replaces" , "Replaces" )
50+
4951intended_status_mapping = {
5052 "BCP" : name (IntendedStatusName , "bcp" , "Best Current Practice" ),
5153 "Draft Standard" : name (IntendedStatusName , "ds" , name = "Draft Standard" ),
@@ -145,7 +147,7 @@ def iesg_login_to_email(l):
145147def date_in_match (match ):
146148 return datetime .date (int (match .group ('year' )), int (match .group ('month' )), int (match .group ('day' )))
147149
148- re_telechat_agenda = re .compile (r"(Placed on|Removed from) agenda for telechat - %s by" % date_re_str )
150+ re_telechat_agenda = re .compile (r"(Placed on|Removed from) agenda for telechat(| - %s) by" % date_re_str )
149151re_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>.*)" )
150152re_ballot_issued = re .compile (r"Ballot has been issued(| by)" )
151153re_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>.*))" )
@@ -191,14 +193,18 @@ def date_in_match(match):
191193# d.std_level =
192194# d.authors =
193195# d.related =
194- d .ad = iesg_login_to_email (o .idinternal .job_owner )
196+ d .ad = iesg_login_to_email (o .idinternal .job_owner ) if o . idinternal else None
195197 d .shepherd = None
196198 d .notify = o .idinternal .state_change_notice_to or "" if o .idinternal else ""
197199 d .external_url = ""
198200 d .note = o .idinternal .note or "" if o .idinternal else ""
199201 d .internal_comments = o .comments or "" # FIXME: maybe put these somewhere else
200202 d .save ()
201203
204+ # make sure our alias is updated
205+ DocAlias .objects .filter (name = d .name ).exclude (document = d ).delete ()
206+ d_alias , _ = DocAlias .objects .get_or_create (name = d .name , document = d )
207+
202208 # clear already imported events
203209 d .event_set .all ().delete ()
204210
@@ -382,21 +388,60 @@ def date_in_match(match):
382388 save_event (d , e , c )
383389
384390 # stop typical comments from being output
385- typical_comments = ["Who is the Document Shepherd for this document" ,
386- "We understand that this document doesn't require any IANA actions" ,
391+ typical_comments = [
392+ "Document Shepherd Write-up for %s" % d .name ,
393+ "Who is the Document Shepherd for this document" ,
394+ "We understand that this document doesn't require any IANA actions" ,
387395 ]
388396 for t in typical_comments :
389397 if t in c .comment_text :
390398 handled = True
391399 break
392400
393401 if not handled :
394- print "couldn't handle %s '%s'" % (c .id , c .comment_text .replace ("\n " , "" ).replace ("\r " , "" ))
402+ print "couldn't handle %s '%s'" % (c .id , c .comment_text .replace ("\n " , "" ).replace ("\r " , "" )[ 0 : 80 ] )
395403
396404
397- # import events that might be missing, we can't be sure where
398- # to place them but if we don't generate them, we'll be
399- # missing the information completely
405+ # import missing revision changes from DraftVersions
406+ known_revisions = set (e .newrevision .rev for e in d .event_set .filter (type = "new_revision" ).select_related ('newrevision' ))
407+ for v in DraftVersions .objects .filter (filename = d .name ).order_by ("revision" ):
408+ if v .revision not in known_revisions :
409+ e = NewRevision (type = "new_revision" )
410+ e .rev = v .revision
411+ # we don't have time information in this source, so
412+ # hack the seconds to include the revision to ensure
413+ # they're ordered correctly
414+ e .time = datetime .datetime .combine (v .revision_date , datetime .time (0 , 0 , int (v .revision )))
415+ e .by = system_email
416+ e .doc = d
417+ e .desc = "New version available"
418+ e .save ()
419+ known_revisions .add (v .revision )
420+
421+ # import events that might be missing, we can't be sure where
422+ # to place them but if we don't generate them, we'll be
423+ # missing the information completely
424+ e = d .latest_event (Event , type = "iesg_approved" )
425+ approved_date = e .time .date () if e else None
426+ if o .b_approve_date != approved_date :
427+ e = Event (type = "iesg_approved" )
428+ e .time = o .idinternal .b_approve_date
429+ e .by = system_email
430+ e .doc = d
431+ e .desc = "IESG has approved"
432+ e .save ()
433+
434+ if o .lc_expiration_date :
435+ e = Expiration (type = "sent_last_call" , expires = o .lc_expiration_date )
436+ e .time = o .lc_sent_date
437+ # let's try to figure out who did it
438+ events = d .event_set .filter (type = "changed_document" , desc__contains = " to <b>In Last Call</b>" ).order_by ('-time' )[:1 ]
439+ e .by = events [0 ].by if events else system_email
440+ e .doc = d
441+ e .desc = "Last call sent"
442+ e .save ()
443+
444+ if o .idinternal :
400445 e = d .latest_event (Status , type = "changed_status_date" )
401446 status_date = e .date if e else None
402447 if o .idinternal .status_date != status_date :
@@ -407,65 +452,36 @@ def date_in_match(match):
407452 e .desc = "Status date has been changed to <b>%s</b> from <b>%s</b>" % (o .idinternal .status_date , status_date )
408453 e .save ()
409454
410- e = d .latest_event (Event , type = "iesg_approved" )
411- approved_date = e .time .date () if e else None
412- if o .b_approve_date != approved_date :
413- e = Event (type = "iesg_approved" )
414- e .time = o .idinternal .b_approve_date
415- e .by = system_email
416- e .doc = d
417- e .desc = "IESG has approved"
418- e .save ()
455+ e = d .latest_event (Telechat , type = "scheduled_for_telechat" )
456+ telechat_date = e .telechat_date if e else None
457+ if not o .idinternal .agenda :
458+ o .idinternal .telechat_date = None # normalize
419459
420- if o .lc_expiration_date :
421- e = Expiration (type = "sent_last_call" , expires = o .lc_expiration_date )
422- e .time = o .lc_sent_date
423- # let's try to figure out who did it
424- events = d .event_set .filter (type = "changed_document" , desc__contains = " to <b>In Last Call</b>" ).order_by ('-time' )[:1 ]
425- e .by = events [0 ].by if events else system_email
460+ if telechat_date != o .idinternal .telechat_date :
461+ e = Telechat (type = "scheduled_for_telechat" ,
462+ telechat_date = o .idinternal .telechat_date ,
463+ returning_item = bool (o .idinternal .returning_item ))
464+ e .time = made_up_date # FIXME: this isn't good, will override new values, estimate one instead
465+ e .by = system_email
466+ args = ("Placed on" , o .idinternal .telechat_date ) if o .idinternal .telechat_date else ("Removed from" , telechat_date )
426467 e .doc = d
427- e .desc = "Last call sent"
468+ e .desc = "%s agenda for telechat - %s by system" % args
428469 e .save ()
429-
430- if o .idinternal :
431- e = d .latest_event (Telechat , type = "scheduled_for_telechat" )
432- telechat_date = e .telechat_date if e else None
433- if not o .idinternal .agenda :
434- o .idinternal .telechat_date = None # normalize
435-
436- if telechat_date != o .idinternal .telechat_date :
437- e = Telechat (type = "scheduled_for_telechat" ,
438- telechat_date = o .idinternal .telechat_date ,
439- returning_item = bool (o .idinternal .returning_item ))
440- e .time = made_up_date
441- e .by = system_email
442- args = ("Placed on" , o .idinternal .telechat_date ) if o .idinternal .telechat_date else ("Removed from" , telechat_date )
443- e .doc = d
444- e .desc = "%s agenda for telechat - %s by system" % args
445- e .save ()
446470
447471 # FIXME: import writeups
448472
473+ # import other attributes
474+
449475 # RFC alias
450476 if o .rfc_number :
451477 rfc_name = "rfc%s" % o .rfc_number
452478 DocAlias .objects .get_or_create (document = d , name = rfc_name )
453-
454- # import missing revision changes from DraftVersions
455- known_revisions = set (e .newrevision .rev for e in d .event_set .filter (type = "new_revision" ).select_related ('newrevision' ))
456- for v in DraftVersions .objects .filter (filename = d .name ).order_by ("revision" ):
457- if v .revision not in known_revisions :
458- e = NewRevision (type = "new_revision" )
459- e .rev = v .revision
460- # we don't have time information in this source, so
461- # hack the seconds to include the revision to ensure
462- # they're ordered correctly
463- e .time = datetime .datetime .combine (v .revision_date , datetime .time (0 , 0 , int (v .revision )))
464- e .by = system_email
465- e .doc = d
466- e .desc = "New version available"
467- e .save ()
468- known_revisions .add (v .revision )
479+ # FIXME: some RFCs seem to be called rfc1234bis?
480+
481+ if o .replaced_by :
482+ replacement , _ = Document .objects .get_or_create (name = o .replaced_by .filename )
483+ RelatedDocument .objects .get_or_create (document = replacement , doc_alias = d_alias , relationship = relationship_replaces )
484+
469485
470486 print "imported" , d .name , " - " , d .iesg_state
471487
@@ -503,8 +519,8 @@ class CheckListInternetDraft(models.Model):
503519# rfc_number = models.IntegerField(null=True, blank=True, db_index=True)
504520# comments = models.TextField(blank=True,null=True)
505521# last_modified_date = models.DateField()
506- replaced_by = BrokenForeignKey ('self' , db_column = 'replaced_by' , blank = True , null = True , related_name = 'replaces_set' )
507- replaces = FKAsOneToOne ('replaces' , reverse = True )
522+ # replaced_by = BrokenForeignKey('self', db_column='replaced_by', blank=True, null=True, related_name='replaces_set')
523+ # replaces = FKAsOneToOne('replaces', reverse=True)
508524 review_by_rfc_editor = models .BooleanField ()
509525 expired_tombstone = models .BooleanField ()
510526# idinternal = FKAsOneToOne('idinternal', reverse=True, query=models.Q(rfc_flag = 0))
0 commit comments