Properly remove "confirm preview" checkbox on broken uploads
authorMagnus Hagander <magnus@hagander.net>
Tue, 27 May 2025 12:29:10 +0000 (14:29 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 27 May 2025 12:29:10 +0000 (14:29 +0200)
When an image uploaded as a sponsor benefit was broken (unparseable), we
would incorrectly still show the "confirm preview looks ok" checkbox
below the error message. If the user confirmed that the preview (which
was non-existant and replaced with an error message) looked OK, we would
store an empty image in the database and consider the benefit OK.

Instead, we're of course not supposed to show the preview checkbox at
all if the image uploaded is broken.

postgresqleu/confsponsor/benefitclasses/imageupload.py

index 6e5afc27bd8f4776fd21489cfd6f0380f753f70a..e951145f622fa5abfa66f1d7a1fe20a2f19204d4 100644 (file)
@@ -75,7 +75,8 @@ class ImageUploadForm(BaseBenefitForm):
                 if 'image' not in self._errors:
                     # Unless there is an error already flagged in the clean_image method
                     self._errors['image'] = self.error_class(['This field is required'])
-                    self._delete_stage2_fields()
+
+                self._delete_stage2_fields()
 
         return self.cleaned_data