Fix handling of contradictory input in image upload (PRETIXEU-78F)

This commit is contained in:
Raphael Michel
2022-09-12 13:17:42 +02:00
parent db93981bac
commit dcec0b03d4

View File

@@ -51,6 +51,7 @@ from django.core.validators import (
) )
from django.db.models import QuerySet from django.db.models import QuerySet
from django.forms import Select, widgets from django.forms import Select, widgets
from django.forms.widgets import FILE_INPUT_CONTRADICTION
from django.utils.formats import date_format from django.utils.formats import date_format
from django.utils.html import escape from django.utils.html import escape
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
@@ -429,7 +430,7 @@ class PortraitImageWidget(UploadedFileWidget):
def value_from_datadict(self, data, files, name): def value_from_datadict(self, data, files, name):
d = super().value_from_datadict(data, files, name) d = super().value_from_datadict(data, files, name)
if d is not None and d is not False: if d is not None and d is not False and d is not FILE_INPUT_CONTRADICTION:
d._cropdata = json.loads(data.get(name + '_cropdata', '{}') or '{}') d._cropdata = json.loads(data.get(name + '_cropdata', '{}') or '{}')
return d return d