From f4ac780d58b1f30df1b2eeef75d8a8e4d75070ec Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Tue, 24 Sep 2024 14:47:05 +0200 Subject: [PATCH] restore anonymized report info before the reports --- .../management/commands/restore_reports_long_term.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scipost_django/submissions/management/commands/restore_reports_long_term.py b/scipost_django/submissions/management/commands/restore_reports_long_term.py index 6262ced66..381fe1d9d 100644 --- a/scipost_django/submissions/management/commands/restore_reports_long_term.py +++ b/scipost_django/submissions/management/commands/restore_reports_long_term.py @@ -73,6 +73,12 @@ class Command(BaseCommand): else: reports_to_restore = [arc.report for arc in ARCs] + # Bulk-update the ARCs before updating the reports + AnonymizedReportContributor.objects.bulk_update( + ARCs, + ["anonymized_author", "original_author", "invitation_email"], + ) + updated_objects = [] for report in reports_to_restore: updated_objects.append( @@ -83,11 +89,7 @@ class Command(BaseCommand): ARCs, reports, invitations = zip(*updated_objects) invitations = list(itertools.chain.from_iterable(invitations)) - # Bulk-update the ARCs, reports, and invitations since commit=False - AnonymizedReportContributor.objects.bulk_update( - ARCs, - ["anonymized_author", "original_author", "invitation_email"], - ) + # Bulk-update the reports, and invitations since commit=False Report.objects.bulk_update(reports, ["author"]) RefereeInvitation.objects.bulk_update( invitations, -- GitLab