Skip to content

Commit df1a915

Browse files
committed
Fix stream auto-detection, skip WG Document state on individual
submission, set WG on adopted individual submission, fix some more content type bugs, fix bug with incorrectly imported AnnotationTag - Legacy-Id: 3860
1 parent da625e5 commit df1a915

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

redesign/importing/import-docs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -791,21 +791,19 @@ def import_from_idinternal(d, idinternal):
791791
d.set_state(state_mapping[o.status.status])
792792

793793
# try guess stream to have a default for old submissions
794+
d.stream = None
794795
if o.filename.startswith("draft-iab-"):
795796
d.stream = stream_mapping["IAB"]
796797
elif o.filename.startswith("draft-irtf-"):
797798
d.stream = stream_mapping["IRTF"]
798799
elif o.idinternal and o.idinternal.via_rfc_editor:
799800
d.stream = stream_mapping["INDEPENDENT"]
800-
else:
801+
elif d.name.startswith("draft-ietf-") and (d.group.type_id != "individ" or state_mapping[o.status.status].slug == "rfc" or o.idinternal):
801802
d.stream = stream_mapping["IETF"]
802803

803-
try:
804-
old_stream = StreamedID.objects.get(draft=o).stream
805-
if old_stream:
806-
d.stream = stream_mapping[old_stream.name]
807-
except StreamedID.DoesNotExist:
808-
pass
804+
sid = StreamedID.objects.filter(draft=o)
805+
if sid and sid[0].stream:
806+
d.stream = stream_mapping[sid[0].stream.name]
809807

810808
d.unset_state("draft-iesg")
811809
try:
@@ -814,7 +812,7 @@ def import_from_idinternal(d, idinternal):
814812
except StateOld.DoesNotExist:
815813
s = None
816814

817-
if s:
815+
if s and not (s.name == "WG Document" and d.group.type_id == "individ"):
818816
try:
819817
# there may be a mismatch between the stream type and the
820818
# state because of a bug in the ietfworkflows code so try
@@ -823,6 +821,10 @@ def import_from_idinternal(d, idinternal):
823821
except State.MultipleObjectsReturned:
824822
d.set_state(State.objects.get(type="draft-stream-%s" % d.stream_id, name=s.name))
825823

824+
# there was a bug in ietfworkflows so the group wasn't set on adopted documents
825+
if s.name in ("Call for Adoption by WG Issued", "Adopted by a WG") and d.group.type_id == "individ" and o.replaced_by and o.replaced_by.group:
826+
d.group = Group.objects.get(acronym=o.replaced_by.group.acronym)
827+
826828
d.rev = o.revision_display()
827829
d.abstract = o.abstract
828830
d.pages = o.txt_page_count
@@ -886,8 +888,7 @@ def import_from_idinternal(d, idinternal):
886888
d.rev = revs[0]
887889

888890
# ietfworkflows history entries
889-
ctype = ContentType.objects.get_for_model(o)
890-
for h in ObjectHistoryEntry.objects.filter(content_type=ctype, content_id=o.pk).order_by('date', 'id'):
891+
for h in ObjectHistoryEntry.objects.filter(content_type=old_internetdraft_content_type_id, content_id=o.pk).order_by('date', 'id'):
891892
e = DocEvent(type="changed_document")
892893
e.time = h.date
893894
e.by = old_person_to_person(h.person)
@@ -1007,8 +1008,7 @@ def import_from_idinternal(d, idinternal):
10071008
# tags
10081009
sync_tag(d, o.review_by_rfc_editor, tag_review_by_rfc_editor)
10091010

1010-
ctype = ContentType.objects.get_for_model(o)
1011-
used_tags = AnnotationTag.objects.filter(annotationtagobjectrelation__content_type=ctype, annotationtagobjectrelation__content_id=o.pk).values_list('name', flat=True)
1011+
used_tags = DocTagName.objects.filter(name__in=list(AnnotationTag.objects.filter(annotationtagobjectrelation__content_type=old_internetdraft_content_type_id, annotationtagobjectrelation__content_id=o.pk).values_list('name', flat=True))).values_list('slug', flat=True)
10121012
possible_tags = get_tags_for_stream_id(d.stream_id)
10131013
for name in possible_tags:
10141014
if name == "need-rev" and o.idinternal and o.idinternal.cur_sub_state and o.idinternal.cur_sub_state.sub_state == "Revised ID Needed":

0 commit comments

Comments
 (0)