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 6262ced660198855e62f8421c6e943f5e0b98abb..381fe1d9ddf248241f4d05952af230b72816ea3f 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,