Skip to content

Commit

Permalink
chore: Move/copy RelatedDocuments to rfcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-richards committed Jul 6, 2023
1 parent 563b5a9 commit 9f1b05a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ def forward(apps, schema_editor):
DocAlias = apps.get_model("doc", "DocAlias")
Document = apps.get_model("doc", "Document")
RelatedDocument = apps.get_model("doc", "RelatedDocument")
for rfc_alias in DocAlias.objects.filter(name__startswith="rfc"):
for rfc_alias in DocAlias.objects.filter(name__startswith="rfc").exclude(
docs__type__slug="rfc"
):
# Move these over to the RFC
RelatedDocument.objects.filter(
relationship__slug__in=(
"tobcp",
Expand All @@ -21,6 +24,17 @@ def forward(apps, schema_editor):
),
source__docalias=rfc_alias,
).update(source=Document.objects.get(name=rfc_alias.name))
# Duplicate references on the RFC but keep the ones on the draft as well
originals = list(
RelatedDocument.objects.filter(
relationship__slug__in=("refinfo", "refnorm", "refold", "refunk"),
source__docalias=rfc_alias,
)
)
for o in originals:
o.pk = None
o.source = Document.objects.get(name=rfc_alias.name)
RelatedDocument.objects.bulk_create(originals)


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion ietf/doc/migrations/0010_move_rfc_docaliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def forward(apps, schema_editor):

class Migration(migrations.Migration):
dependencies = [
("doc", "0009_move_rfc_relateddocuments"),
("doc", "0009_rfc_relateddocuments"),
]

operations = [
Expand Down

0 comments on commit 9f1b05a

Please sign in to comment.