forked from CGM_Public/pretix_original
Refs #44 -- Added background queue support for file export
This commit is contained in:
@@ -19,4 +19,4 @@ class EventMiddleware:
|
||||
organizer__slug=url.kwargs['organizer'],
|
||||
).select_related('organizer')[0]
|
||||
except IndexError:
|
||||
return HttpResponseNotFound() # TODO: Provide error message
|
||||
return HttpResponseNotFound('Unknown event') # TODO: Provide error message
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{% load compress %}
|
||||
{% load i18n %}
|
||||
{% load staticfiles %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ settings.PRETIX_INSTANCE_NAME }}</title>
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" type="text/less" href="{% static "pretixpresale/less/cachedfiles.less" %}" />
|
||||
{% endcompress %}
|
||||
{% compress js %}
|
||||
<script type="text/javascript" src="{% static "jquery/js/jquery-2.1.1.min.js" %}"></script>
|
||||
{% endcompress %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<i class="fa fa-cog big-animated-icon"></i>
|
||||
<h1>{% trans "We are preparing your file for download…" %}</h1>
|
||||
<p>
|
||||
{% trans "If this takes longer than a few minutes, please contact us." %}
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
window.setInterval(function() {
|
||||
$.get(location.href + '?ajax=1', function(data, status) {
|
||||
if (data === "1") {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.conf.urls import include, url
|
||||
|
||||
import pretix.presale.views.cachedfiles
|
||||
import pretix.presale.views.cart
|
||||
import pretix.presale.views.checkout
|
||||
import pretix.presale.views.event
|
||||
@@ -7,6 +8,8 @@ import pretix.presale.views.locale
|
||||
import pretix.presale.views.order
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^download/(?P<id>[^/]+)/$', pretix.presale.views.cachedfiles.DownloadView.as_view(),
|
||||
name='cachedfile.download'),
|
||||
url(r'^(?P<organizer>[^/]+)/(?P<event>[^/]+)/', include([
|
||||
url(r'^$', pretix.presale.views.event.EventIndex.as_view(), name='event.index'),
|
||||
url(r'^cart/add$', pretix.presale.views.cart.CartAdd.as_view(), name='event.cart.add'),
|
||||
|
||||
22
src/pretix/presale/views/cachedfiles.py
Normal file
22
src/pretix/presale/views/cachedfiles.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.utils.functional import cached_property
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from pretix.base.models import CachedFile
|
||||
|
||||
|
||||
class DownloadView(TemplateView):
|
||||
template_name = "pretixpresale/cachedfiles/pending.html"
|
||||
|
||||
@cached_property
|
||||
def object(self):
|
||||
return get_object_or_404(CachedFile, id=self.kwargs['id'])
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if 'ajax' in request.GET:
|
||||
return HttpResponse('1' if self.object.file else '0')
|
||||
elif self.object.file:
|
||||
return redirect(self.object.file.url)
|
||||
else:
|
||||
return super().get(request, *args, **kwargs)
|
||||
Reference in New Issue
Block a user