From 6a50054812e6cb30e04d96f0d70026f3bc9092af Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sat, 30 Mar 2019 10:16:36 +0100
Subject: [PATCH] Add management command to check submission metadata
 correctness

---
 .../commands/check_submission_metadata.py     | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 conflicts/management/commands/check_submission_metadata.py

diff --git a/conflicts/management/commands/check_submission_metadata.py b/conflicts/management/commands/check_submission_metadata.py
new file mode 100644
index 000000000..de99fe359
--- /dev/null
+++ b/conflicts/management/commands/check_submission_metadata.py
@@ -0,0 +1,24 @@
+__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
+__license__ = "AGPL v3"
+
+
+import traceback
+
+from django.core.management.base import BaseCommand
+
+from submissions.models import Submission
+
+
+class Command(BaseCommand):
+    """Verify the metadata formatting and flag errors."""
+
+    def handle(self, *args, **kwargs):
+        for sub in Submission.objects.all():
+            # Check that the author list is properly formatted
+            try:
+                if True or 'entries' in sub.metadata:
+                    author_str_list = [
+                        a['name'].split()[-1] for a in sub.metadata['entries'][0]['authors']]
+            except:
+                print('Error for %s' % sub.preprint)
+                traceback.print_exc()
-- 
GitLab