Merge pull request #367 from ThomasWaldmann/http-error

http error templates simplified, catch session-saving OperationalError
This commit is contained in:
TW 2018-10-01 17:21:14 +02:00 committed by GitHub
commit 90e59c7a89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 9 deletions

View File

@ -13,6 +13,7 @@ from .main.dnstools import put_ip_into_session
from .main.iptools import normalize_ip
from django.conf import settings
from django.db import OperationalError
MAX_IP_AGE = 180 # seconds
@ -63,5 +64,11 @@ def update_ips(request):
# if we have a new session (== not loaded from database / storage), we
# MUST save it here to create its session_key as the base.html template
# uses .session_key to build the URL for detectip:
s.save()
try:
s.save()
except OperationalError:
# if e.g. the database is locked (sqlite), do not blow up here,
# because it gives rather ugly tracebacks in the email even if django
# was just rendering the 404 template for the current request, see #356.
pass
return {}

View File

@ -1,10 +1,14 @@
{% extends "base.html" %}
{% load i18n %}{% load bootstrap %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ WWW_HOST }} - something went wrong...</title>
</head>
<body>
{% block content %}
<div class="row">
{% block error %}
{% endblock %}
</div>
{% endblock %}
{% block error %}
{% endblock %}
<a href="{% url 'home' %}">Back to {{ WWW_HOST }}.</a>
</body>
</html>