Repository: comic/grand-challenge.org

Issue:
Cannot upload prediction.json
**Describe the bug**
Cannot upload a .json directly to an input upload field.


Create a simple 'predictions.json' file and try to upload at https://demo.gc.localhost/evaluation/phase-2/submissions/create/.

# Expected
Successful upload

# Actual result
![image](https://github.com/comic/grand-challenge.org/assets/7871310/bd552702-5909-4666-8ae1-d314949baf51)



Discussion:

Resolving patch:
diff --git a/app/grandchallenge/evaluation/forms.py b/app/grandchallenge/evaluation/forms.py
--- a/app/grandchallenge/evaluation/forms.py
+++ b/app/grandchallenge/evaluation/forms.py
@@ -246,6 +246,7 @@ class SubmissionForm(
                 "application/vnd.ms-excel",
                 "text/csv",
                 "text/plain",
+                "application/json",
             ]
         ),
         label="Predictions File",
diff --git a/app/grandchallenge/evaluation/migrations/0036_alter_submission_predictions_file.py b/app/grandchallenge/evaluation/migrations/0036_alter_submission_predictions_file.py
new file mode 100644
--- /dev/null
+++ b/app/grandchallenge/evaluation/migrations/0036_alter_submission_predictions_file.py
@@ -0,0 +1,38 @@
+# Generated by Django 4.1.9 on 2023-06-19 13:54
+
+from django.db import migrations, models
+
+import grandchallenge.core.storage
+import grandchallenge.core.validators
+import grandchallenge.evaluation.models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("evaluation", "0035_alter_phase_submissions_close_at_and_more"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="submission",
+            name="predictions_file",
+            field=models.FileField(
+                blank=True,
+                storage=grandchallenge.core.storage.ProtectedS3Storage(),
+                upload_to=grandchallenge.evaluation.models.submission_file_path,
+                validators=[
+                    grandchallenge.core.validators.MimeTypeValidator(
+                        allowed_types=(
+                            "application/zip",
+                            "text/plain",
+                            "application/json",
+                        )
+                    ),
+                    grandchallenge.core.validators.ExtensionValidator(
+                        allowed_extensions=(".zip", ".csv", ".json")
+                    ),
+                ],
+            ),
+        ),
+    ]
diff --git a/app/grandchallenge/evaluation/models.py b/app/grandchallenge/evaluation/models.py
--- a/app/grandchallenge/evaluation/models.py
+++ b/app/grandchallenge/evaluation/models.py
@@ -816,8 +816,20 @@ class Submission(UUIDModel):
     predictions_file = models.FileField(
         upload_to=submission_file_path,
         validators=[
-            MimeTypeValidator(allowed_types=("application/zip", "text/plain")),
-            ExtensionValidator(allowed_extensions=(".zip", ".csv")),
+            MimeTypeValidator(
+                allowed_types=(
+                    "application/zip",
+                    "text/plain",
+                    "application/json",
+                )
+            ),
+            ExtensionValidator(
+                allowed_extensions=(
+                    ".zip",
+                    ".csv",
+                    ".json",
+                )
+            ),
         ],
         storage=protected_s3_storage,
         blank=True,


Test patch: