Skip to content

Commit 7deeb60

Browse files
committed
Review and import more attributes from InternetDraft, fix proxy bugs
- Legacy-Id: 2729
1 parent c5b0b9c commit 7deeb60

3 files changed

Lines changed: 75 additions & 32 deletions

File tree

redesign/doc/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __unicode__(self):
119119
return "%s-->%s" % (self.name, self.document.name)
120120
document_link = admin_link("document")
121121
class Meta:
122-
verbose_name_plural="Aliases"
122+
verbose_name_plural = "aliases"
123123

124124
class SendQueue(models.Model):
125125
time = models.DateTimeField() # Scheduled at this time
@@ -154,6 +154,7 @@ class SendQueue(models.Model):
154154
# misc document events
155155
("added_comment", "Added comment"),
156156
("added_tombstone", "Added tombstone"),
157+
("expired_document", "Expired document"),
157158
("requested_resurrect", "Requested resurrect"),
158159

159160
# IESG events
@@ -164,8 +165,8 @@ class SendQueue(models.Model):
164165
("changed_ballot_writeup_text", "Changed ballot writeup text"),
165166

166167
("changed_last_call_text", "Changed last call text"),
167-
("sent_last_call", "Sent last call"),
168168
("requested_last_call", "Requested last call"),
169+
("sent_last_call", "Sent last call"),
169170

170171
("changed_status_date", "Changed status date"),
171172

@@ -218,7 +219,7 @@ class Expiration(Event):
218219
expires = models.DateTimeField()
219220

220221
class Telechat(Event):
221-
telechat_date = models.DateField()
222+
telechat_date = models.DateField(blank=True, null=True)
222223
returning_item = models.BooleanField(default=False)
223224

224225

redesign/doc/proxy.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def txt_page_count(self):
6262
#start_date = models.DateField()
6363
@property
6464
def start_date(self):
65-
return self.dochistory_set.dates("time","day","ASC")[0]
65+
e = NewRevision.objects.filter(doc=self).order_by("time")[:1]
66+
return e[0].time.date() if e else None
6667
#expiration_date = models.DateField()
6768
@property
6869
def expiration_date(self):
@@ -119,10 +120,8 @@ def b_approve_date(self):
119120
#rfc_number = models.IntegerField(null=True, blank=True, db_index=True)
120121
@property
121122
def rfc_number(self):
122-
try:
123-
self.docalias_set.filter(name__startswith="rfc")[0].name[3:]
124-
except IndexError:
125-
return None
123+
aliases = self.docalias_set.filter(name__startswith="rfc")
124+
return int(aliases[0].name[3:]) if aliases else None
126125

127126
#comments = models.TextField(blank=True) # unused
128127

redesign/import-document-state.py

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# IESGComment, IESGDiscuss, DocumentComment, idrfc.DraftVersions
3737

3838
def name(name_class, slug, name, desc=""):
39-
# create if it doesn't exist, set name
39+
# create if it doesn't exist, set name and desc
4040
obj, _ = name_class.objects.get_or_create(slug=slug)
4141
obj.name = name
4242
obj.desc = desc
@@ -147,7 +147,7 @@ def date_in_match(match):
147147

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>.*)")
150-
re_ballot_issued = re.compile(r"Ballot has been issued by")
150+
re_ballot_issued = re.compile(r"Ballot has been issued(| by)")
151151
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>.*))")
152152
re_note_changed = re.compile(r"(\[Note\]: .*'.*'|Note field has been cleared)")
153153
re_draft_added = re.compile(r"Draft [Aa]dded (by .*)?( in state (?P<state>.*))?")
@@ -158,7 +158,10 @@ def date_in_match(match):
158158
re_responsible_ad_changed = re.compile(r"(Responsible AD|Shepherding AD) has been changed to (<b>)?")
159159
re_intended_status_changed = re.compile(r"Intended [sS]tatus has been changed to (<b>)?")
160160
re_state_change_notice = re.compile(r"State Change Notice email list (have been change|has been changed) (<b>)?")
161-
161+
162+
163+
made_up_date = datetime.datetime(2030, 1, 1, 0, 0, 0)
164+
162165
all_drafts = InternetDraft.objects.all().select_related()
163166
if draft_name_to_import:
164167
all_drafts = all_drafts.filter(filename=draft_name_to_import)
@@ -209,7 +212,7 @@ def date_in_match(match):
209212
if match:
210213
e = Telechat()
211214
e.type = "scheduled_for_telechat"
212-
e.telechat_date = date_in_match(match)
215+
e.telechat_date = date_in_match(match) if "Placed on" in c.comment_text else None
213216
# can't extract this from history so we just take the latest value
214217
e.returning_item = bool(o.idinternal.returning_item)
215218
save_event(d, e, c)
@@ -313,6 +316,12 @@ def date_in_match(match):
313316
save_event(d, e, c)
314317
handled = True
315318

319+
# document expiration
320+
if c.comment_text == "Document is expired by system":
321+
e = Event(type="expired_document")
322+
save_event(d, e, c)
323+
handled = True
324+
316325
# approved document
317326
match = re_document_approved.search(c.comment_text)
318327
if match:
@@ -384,13 +393,15 @@ def date_in_match(match):
384393
if not handled:
385394
print "couldn't handle %s '%s'" % (c.id, c.comment_text.replace("\n", "").replace("\r", ""))
386395

387-
# import events that might be missing, we don't know where to
388-
# place them but if we don't generate them, we'll be missing
389-
# the information completely
396+
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
390400
e = d.latest_event(Status, type="changed_status_date")
391401
status_date = e.date if e else None
392402
if o.idinternal.status_date != status_date:
393403
e = Status(type="changed_status_date", date=o.idinternal.status_date)
404+
e.time = made_up_date
394405
e.by = system_email
395406
e.doc = d
396407
e.desc = "Status date has been changed to <b>%s</b> from <b>%s</b>" % (o.idinternal.status_date, status_date)
@@ -406,8 +417,40 @@ def date_in_match(match):
406417
e.desc = "IESG has approved"
407418
e.save()
408419

409-
# FIXME: import writeups
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
426+
e.doc = d
427+
e.desc = "Last call sent"
428+
e.save()
410429

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()
446+
447+
# FIXME: import writeups
448+
449+
# RFC alias
450+
if o.rfc_number:
451+
rfc_name = "rfc%s" % o.rfc_number
452+
DocAlias.objects.get_or_create(document=d, name=rfc_name)
453+
411454
# import missing revision changes from DraftVersions
412455
known_revisions = set(e.newrevision.rev for e in d.event_set.filter(type="new_revision").select_related('newrevision'))
413456
for v in DraftVersions.objects.filter(filename=d.name).order_by("revision"):
@@ -424,7 +467,7 @@ def date_in_match(match):
424467
e.save()
425468
known_revisions.add(v.revision)
426469

427-
print "imported", d.name, "S:", d.iesg_state
470+
print "imported", d.name, " - ", d.iesg_state
428471

429472

430473

@@ -439,27 +482,27 @@ class CheckListInternetDraft(models.Model):
439482
# group = models.ForeignKey(Acronym, db_column='group_acronym_id')
440483
# filename = models.CharField(max_length=255, unique=True)
441484
# revision = models.CharField(max_length=2)
442-
revision_date = models.DateField()
443-
file_type = models.CharField(max_length=20)
485+
# revision_date = models.DateField()
486+
# file_type = models.CharField(max_length=20)
444487
# txt_page_count = models.IntegerField()
445-
local_path = models.CharField(max_length=255, blank=True, null=True)
446-
start_date = models.DateField()
447-
expiration_date = models.DateField(null=True)
488+
# local_path = models.CharField(max_length=255, blank=True, null=True)
489+
# start_date = models.DateField()
490+
# expiration_date = models.DateField(null=True)
448491
# abstract = models.TextField()
449-
dunn_sent_date = models.DateField(null=True, blank=True)
450-
extension_date = models.DateField(null=True, blank=True)
492+
# dunn_sent_date = models.DateField(null=True, blank=True)
493+
# extension_date = models.DateField(null=True, blank=True)
451494
# status = models.ForeignKey(IDStatus)
452495
# intended_status = models.ForeignKey(IDIntendedStatus)
453-
lc_sent_date = models.DateField(null=True, blank=True)
454-
lc_changes = models.CharField(max_length=3,null=True)
455-
lc_expiration_date = models.DateField(null=True, blank=True)
456-
b_sent_date = models.DateField(null=True, blank=True)
457-
b_discussion_date = models.DateField(null=True, blank=True)
496+
# lc_sent_date = models.DateField(null=True, blank=True)
497+
# lc_changes = models.CharField(max_length=3,null=True)
498+
# lc_expiration_date = models.DateField(null=True, blank=True)
499+
# b_sent_date = models.DateField(null=True, blank=True)
500+
# b_discussion_date = models.DateField(null=True, blank=True)
458501
# b_approve_date = models.DateField(null=True, blank=True)
459-
wgreturn_date = models.DateField(null=True, blank=True)
460-
rfc_number = models.IntegerField(null=True, blank=True, db_index=True)
502+
# wgreturn_date = models.DateField(null=True, blank=True)
503+
# rfc_number = models.IntegerField(null=True, blank=True, db_index=True)
461504
# comments = models.TextField(blank=True,null=True)
462-
last_modified_date = models.DateField()
505+
# last_modified_date = models.DateField()
463506
replaced_by = BrokenForeignKey('self', db_column='replaced_by', blank=True, null=True, related_name='replaces_set')
464507
replaces = FKAsOneToOne('replaces', reverse=True)
465508
review_by_rfc_editor = models.BooleanField()

0 commit comments

Comments
 (0)