Skip to content

middleware: Handle OperationalErrors

James Valleroy requested to merge jvalleroy/freedombox:dblock into master

For #1443 (closed).

diff --git a/plinth/urls.py b/plinth/urls.py
index 34c61068c..c81152c95 100644
--- a/plinth/urls.py
+++ b/plinth/urls.py
@@ -32,5 +32,7 @@ urlpatterns = [
 
     # Notifications
     re_path(r'^notification/(?P<id>[A-Za-z0-9-=]+)/dismiss/$',
-            views.notification_dismiss, name='notification_dismiss')
+            views.notification_dismiss, name='notification_dismiss'),
+
+    re_path(r'^operror/$', views.operror, name='operror')
 ]
diff --git a/plinth/views.py b/plinth/views.py
index 8cb5d4c20..499f56cd7 100644
--- a/plinth/views.py
+++ b/plinth/views.py
@@ -9,6 +9,7 @@ import urllib.parse
 
 from django.contrib import messages
 from django.core.exceptions import ImproperlyConfigured
+from django.db.utils import OperationalError
 from django.http import Http404, HttpResponseBadRequest, HttpResponseRedirect
 from django.shortcuts import redirect
 from django.template.response import TemplateResponse
@@ -495,3 +496,7 @@ def notification_dismiss(request, id):
     notes[0].dismiss()
 
     return HttpResponseRedirect(_get_redirect_url_from_param(request))
+
+
+def operror(request):
+    raise OperationalError()

Merge request reports

Loading