mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Fix #1153 -- Show preview of uploaded pictures in the backend
This commit is contained in:
@@ -4,6 +4,7 @@ import os
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files import File
|
||||
from django.forms.utils import from_current_timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -66,11 +67,20 @@ def selector(values, prop):
|
||||
|
||||
|
||||
class ClearableBasenameFileInput(forms.ClearableFileInput):
|
||||
template_name = 'pretixbase/forms/widgets/thumbnailed_file_input.html'
|
||||
|
||||
class FakeFile:
|
||||
class FakeFile(File):
|
||||
def __init__(self, file):
|
||||
self.file = file
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.file.name
|
||||
|
||||
@property
|
||||
def is_img(self):
|
||||
return any(self.file.name.endswith(e) for e in ('.jpg', '.jpeg', '.png', '.gif'))
|
||||
|
||||
def __str__(self):
|
||||
return os.path.basename(self.file.name).split('.', 1)[-1]
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
{{ settings.PRETIX_INSTANCE_NAME }}</title>
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" type="text/x-scss" href="{% static "pretixcontrol/scss/main.scss" %}" />
|
||||
<link rel="stylesheet" type="text/x-scss" href="{% static "lightbox/css/lightbox.scss" %}" />
|
||||
{% endcompress %}
|
||||
{% if DEBUG %}
|
||||
<script type="text/javascript" src="{% url 'javascript-catalog' lang=request.LANGUAGE_CODE %}"
|
||||
@@ -51,6 +52,7 @@
|
||||
<script type="text/javascript" src="{% static "colorpicker/bootstrap-colorpicker.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "fileupload/jquery.ui.widget.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "fileupload/jquery.fileupload.js" %}"></script>
|
||||
<script type="text/javascript" src="{% static "lightbox/js/lightbox.min.js" %}"></script>
|
||||
{% endcompress %}
|
||||
{{ html_head|safe }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user