mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
Do not show absolute file paths to user
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
from django import forms
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from ...base.forms import I18nModelForm
|
||||
@@ -57,7 +58,22 @@ def selector(values, prop):
|
||||
]
|
||||
|
||||
|
||||
class ClearableBasenameFileInput(forms.ClearableFileInput):
|
||||
|
||||
def get_template_substitution_values(self, value):
|
||||
"""
|
||||
Return value-related substitutions.
|
||||
"""
|
||||
bname = os.path.basename(value.name)
|
||||
return {
|
||||
'initial': conditional_escape(bname),
|
||||
'initial_url': conditional_escape(value.url),
|
||||
}
|
||||
|
||||
|
||||
class ExtFileField(forms.FileField):
|
||||
widget = ClearableBasenameFileInput
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
ext_whitelist = kwargs.pop("ext_whitelist")
|
||||
self.ext_whitelist = [i.lower() for i in ext_whitelist]
|
||||
|
||||
@@ -3,6 +3,7 @@ from django.core.files.storage import default_storage
|
||||
|
||||
from pretix.base.i18n import LazyI18nString
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
|
||||
from .signals import footer_link, html_head
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user