Added custom error pages

This commit is contained in:
Raphael Michel
2015-09-17 23:44:07 +02:00
parent 59e4b19e3f
commit c8830cc880
20 changed files with 129 additions and 37 deletions

View File

@@ -0,0 +1,13 @@
{% extends "error.html" %}
{% load i18n %}
{% block title %}{% trans "Bad Request" %}{% endblock %}
{% block content %}
<i class="fa fa-frown-o big-icon"></i>
<h1>{% trans "Bad Request" %}</h1>
<p>{% trans "We were unable to parse your request." %}</p>
<p>{{ exception }}</p>
<p>
<a href="javascript:history.back()">{% trans "Take a step back" %}</a>
&middot; <a href="javascript:location.reload()">{% trans "Try again" %}</a>
</p>
{% endblock %}

View File

@@ -0,0 +1,13 @@
{% extends "error.html" %}
{% load i18n %}
{% block title %}{% trans "Permission denied" %}{% endblock %}
{% block content %}
<i class="fa fa-lock big-icon"></i>
<h1>{% trans "Permission denied" %}</h1>
<p>{% trans "You do not have access to this page." %}</p>
<p>{{ exception }}</p>
<p>
<a href="javascript:history.back()">{% trans "Take a step back" %}</a>
&middot; <a href="javascript:location.reload()">{% trans "Try again" %}</a>
</p>
{% endblock %}

View File

@@ -0,0 +1,12 @@
{% extends "error.html" %}
{% load i18n %}
{% block title %}{% trans "Not found" %}{% endblock %}
{% block content %}
<i class="fa fa-meh-o big-icon"></i>
<h1>{% trans "Not found" %}</h1>
<p>{% trans "I'm afraid we could not find the the resource you requested." %}</p>
<p>{{ exception }}</p>
<p>
<a href="javascript:history.back()">{% trans "Take a step back" %}</a>
</p>
{% endblock %}

View File

@@ -0,0 +1,14 @@
{% extends "error.html" %}
{% load i18n %}
{% block title %}{% trans "Internal Server Error" %}{% endblock %}
{% block content %}
<i class="fa fa-bolt big-icon"></i>
<h1>{% trans "Internal Server Error" %}</h1>
<p>{% trans "We had trouble processing your request." %}</p>
<p>{% trans "If this problem persists, please contact us." %}</p>
<p>{{ exception }}</p>
<p>
<a href="javascript:history.back()">{% trans "Take a step back" %}</a>
&middot; <a href="javascript:location.reload()">{% trans "Try again" %}</a>
</p>
{% endblock %}

View File

@@ -0,0 +1,18 @@
{% load compress %}
{% load i18n %}
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% compress css %}
<link rel="stylesheet" type="text/less" href="{% static "pretixbase/less/error.less" %}" />
{% endcompress %}
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
{% block content %}{% endblock %}
</div>
</body>
</html>

View File

@@ -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 "pretixbase/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>

View File

View 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 = "pretixbase/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)