From: Magnus Hagander Date: Tue, 27 May 2025 12:29:10 +0000 (+0200) Subject: Properly remove "confirm preview" checkbox on broken uploads X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=d6250687da42786374caa956c9ef158ed313d630;p=pgeu-system.git Properly remove "confirm preview" checkbox on broken uploads 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. --- diff --git a/postgresqleu/confsponsor/benefitclasses/imageupload.py b/postgresqleu/confsponsor/benefitclasses/imageupload.py index 6e5afc27..e951145f 100644 --- a/postgresqleu/confsponsor/benefitclasses/imageupload.py +++ b/postgresqleu/confsponsor/benefitclasses/imageupload.py @@ -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