summaryrefslogtreecommitdiff
path: root/pgweb/util/helpers.py
diff options
context:
space:
mode:
authorMagnus Hagander2020-04-04 12:43:27 +0000
committerMagnus Hagander2020-04-04 12:43:27 +0000
commitb405302d973a31e212125081184ab8cf17b0be71 (patch)
tree16a8e7638b481a1ef1b375103c8f76962acf8c97 /pgweb/util/helpers.py
parent454ea7a7be2e99ed292acf7d0fe55c0036d72b3e (diff)
Avoid returning HttpServerError for things not server errors
With the new django, alerts are raised for everything with status 500, not juse exceptions. This put a light on a number of places where we were returning 500 server error code for things that are not actually server errors. Some should be a regular 200 ok with an error message, and others should be a permissions error.
Diffstat (limited to 'pgweb/util/helpers.py')
-rw-r--r--pgweb/util/helpers.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/pgweb/util/helpers.py b/pgweb/util/helpers.py
index 1b0e0ab4..ae2ea6bc 100644
--- a/pgweb/util/helpers.py
+++ b/pgweb/util/helpers.py
@@ -175,6 +175,13 @@ def HttpServerError(request, msg):
return r
+def HttpSimpleResponse(request, title, msg):
+ return render(request, 'simple.html', {
+ 'title': title,
+ 'message': msg,
+ })
+
+
class PgXmlHelper(django.utils.xmlutils.SimplerXMLGenerator):
def __init__(self, outstream, skipempty=False):
django.utils.xmlutils.SimplerXMLGenerator.__init__(self, outstream, 'utf-8')