Compare commits

...

9 Commits

Author SHA1 Message Date
Raphael Michel
0eb5534c4d Bump version to 2023.10.2 2024-02-21 15:39:22 +01:00
Raphael Michel
1ece080fa0 CachedFileField: Do not store file that does not pass validation 2024-02-21 15:39:09 +01:00
Mira Weller
03a302415a forms: fix image file upload in CachedFileField 2024-02-21 15:39:09 +01:00
Mira Weller
0e73611f7c forms: fix bound data retrieval of CachedFile
when re-submitting a form a second time, the cached file got lost
2024-02-21 15:39:09 +01:00
Mira Weller
5fe5b82f1a forms: fix file type validation on CachedFileInput 2024-02-21 15:39:09 +01:00
Raphael Michel
9aa2976bda Bump to 2023.10.1.post1 2024-01-17 22:36:47 +01:00
Raphael Michel
eec60f6242 Bump importlib_metadata to 7 2024-01-17 22:36:44 +01:00
Raphael Michel
c190fc315c Bump to 2023.10.1 2024-01-17 22:32:06 +01:00
Raphael Michel
eebd499359 Fix #3810 -- Stripe: Move to statement_descriptor_suffix 2024-01-17 22:31:18 +01:00
5 changed files with 26 additions and 10 deletions

View File

@@ -59,7 +59,7 @@ dependencies = [
"dnspython==2.3.*",
"drf_ujson2==1.7.*",
"geoip2==4.*",
"importlib_metadata==6.*", # Polyfill, we can probably drop this once we require Python 3.10+
"importlib_metadata==7.*", # Polyfill, we can probably drop this once we require Python 3.10+
"isoweek",
"jsonschema",
"kombu==5.3.*",

View File

@@ -19,4 +19,4 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
__version__ = "2023.10.0"
__version__ = "2023.10.2"

View File

@@ -219,15 +219,17 @@ class ExtValidationMixin:
def clean(self, *args, **kwargs):
data = super().clean(*args, **kwargs)
if isinstance(data, UploadedFile):
filename = data.name
from ...base.models import CachedFile
if isinstance(data, (UploadedFile, CachedFile)):
filename = data.name if isinstance(data, UploadedFile) else data.filename
ext = os.path.splitext(filename)[1]
ext = ext.lower()
if ext not in self.ext_whitelist:
raise forms.ValidationError(_("Filetype not allowed!"))
if ext in IMAGE_EXTS:
validate_uploaded_file_for_valid_image(data)
validate_uploaded_file_for_valid_image(data if isinstance(data, UploadedFile) else data.file)
return data
@@ -257,6 +259,12 @@ class CachedFileField(ExtFileField):
if isinstance(data, File):
if hasattr(data, '_uploaded_to'):
return data._uploaded_to
try:
self.clean(data)
except ValidationError:
return None
cf = CachedFile.objects.create(
expires=now() + datetime.timedelta(days=1),
date=now(),
@@ -268,6 +276,9 @@ class CachedFileField(ExtFileField):
cf.save()
data._uploaded_to = cf
return cf
if isinstance(data, CachedFile):
return data
return super().bound_data(data, initial)
def clean(self, *args, **kwargs):

View File

@@ -44,11 +44,12 @@ def validate_uploaded_file_for_valid_image(f):
# have to read the data into memory.
if hasattr(f, 'temporary_file_path'):
file = f.temporary_file_path()
elif hasattr(f, 'read'):
if hasattr(f, 'seek') and callable(f.seek):
f.seek(0)
file = BytesIO(f.read())
else:
if hasattr(f, 'read'):
file = BytesIO(f.read())
else:
file = BytesIO(f['content'])
file = BytesIO(f['content'])
try:
try:

View File

@@ -924,6 +924,11 @@ class StripePaymentIntentMethod(StripeMethod):
}
})
if self.method == "card":
params['statement_descriptor_suffix'] = self.statement_descriptor(payment)
else:
params['statement_descriptor'] = self.statement_descriptor(payment)
intent = stripe.PaymentIntent.create(
amount=self._get_amount(payment),
currency=self.event.currency.lower(),
@@ -935,7 +940,6 @@ class StripePaymentIntentMethod(StripeMethod):
event=self.event.slug.upper(),
code=payment.order.code
),
statement_descriptor=self.statement_descriptor(payment),
metadata={
'order': str(payment.order.id),
'event': self.event.id,