Repository: ResonantGeoData/ResonantGeoData

Issue:
compute checksum broken on saving new entry
Checking the "compute checksum" flag when uploading an image on the deployed site results in an error page that says "Server Error (500)" and that's all


Discussion:
If I check the "compute checksum" flag on a pre-saved entry then it works. It just doesn't work on a new entry
I've managed to reproduce this locally and I get an error in `rgd.utility._field_file_to_local_path`: `'S3FakeFile' object has no attribute 'open'`

Resolving patch:
diff --git a/rgd/geodata/migrations/0006_auto_20201015_0357.py b/rgd/geodata/migrations/0006_auto_20201015_0357.py
new file mode 100644
--- /dev/null
+++ b/rgd/geodata/migrations/0006_auto_20201015_0357.py
@@ -0,0 +1,33 @@
+# Generated by Django 3.1.2 on 2020-10-15 03:57
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('geodata', '0005_thumbnail'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='arbitraryfile',
+            name='compute_checksum',
+        ),
+        migrations.RemoveField(
+            model_name='convertedimagefile',
+            name='compute_checksum',
+        ),
+        migrations.RemoveField(
+            model_name='fmvfile',
+            name='compute_checksum',
+        ),
+        migrations.RemoveField(
+            model_name='geometryarchive',
+            name='compute_checksum',
+        ),
+        migrations.RemoveField(
+            model_name='imagefile',
+            name='compute_checksum',
+        ),
+    ]
diff --git a/rgd/geodata/models/common.py b/rgd/geodata/models/common.py
--- a/rgd/geodata/models/common.py
+++ b/rgd/geodata/models/common.py
@@ -66,9 +66,6 @@ class ChecksumFile(ModifiableEntry):
 
     name = models.CharField(max_length=100, blank=True, null=True)
     checksum = models.CharField(max_length=64, blank=True, null=True)
-    compute_checksum = models.BooleanField(
-        default=False
-    )  # a flag to recompute the checksum on save
     validate_checksum = models.BooleanField(
         default=False
     )  # a flag to validate the checksum against the saved checksum
@@ -107,19 +104,17 @@ def save(self, *args, **kwargs):
         # Must save the model with the file before accessing it for the checksum
         super(ChecksumFile, self).save(*args, **kwargs)
         # Checksum is additional step after saving everything else - simply update these fields.
-        if self.compute_checksum or self.validate_checksum:
+        if not self.checksum or self.validate_checksum:
             if self.validate_checksum:
                 self.validate()
             else:
                 self.update_checksum()
             # Reset the user flags
-            self.compute_checksum = False
             self.validate_checksum = False
             # Simple update save - not full save
             super(ChecksumFile, self).save(
                 update_fields=[
                     'checksum',
-                    'compute_checksum',
                     'last_validation',
                     'validate_checksum',
                 ]
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@
         'django-girders',
         'django-filter',
         'django-model-utils',
-        'django-s3-file-field>=0.0.12',
+        'django-s3-file-field>=0.0.14',
         'djangorestframework',
         'djproxy',
         'docker',


Test patch:
diff --git a/rgd/geodata/tests/factories.py b/rgd/geodata/tests/factories.py
--- a/rgd/geodata/tests/factories.py
+++ b/rgd/geodata/tests/factories.py
@@ -21,7 +21,6 @@ class Meta:
 
     name = factory.Faker('sentence', nb_words=2)
     file = factory.django.FileField(filename='sample.dat')
-    compute_checksum = True
     # creator = factory.SubFactory(UserFactory)
     # modifier = factory.SubFactory(UserFactory)
 
@@ -54,7 +53,6 @@ class Meta:
 
     name = factory.Faker('sentence', nb_words=2)
     file = factory.django.FileField(filename='sample.dat')
-    compute_checksum = True
 
 
 class ArbitraryFileFactory(factory.django.DjangoModelFactory):