Commit afafec7d authored by dario's avatar dario

web/views: return correct HTTP status on send_pdf_file errors

  * render_template: add HTTP status parameter
parent d68d8e80
......@@ -35,13 +35,14 @@ def theme_for_url(url):
return config.default_theme
def render_template(template, **context):
def render_template(template, status=200, **context):
try:
context['git_commit'] = util.gitVersion.gitVersion(config.basedir)
except:
pass
return Response(jinja_env.get_template(template).render(**context),
status=status,
mimetype='application/xhtml+xml')
......
......@@ -144,8 +144,10 @@ def send_pdf_file(request, pdffile):
pdfid = str_truncate_if_tail_matches(pdffile, ".pdf")
if not pdfid in public_pdf_db:
return render_template('error.xml',
error_text='There is no PDF file with that ID',
theme=local.theme)
status=404,
error_hdr='Error',
error_text='There is no PDF file with that ID',
theme=local.theme)
meta = public_pdf_db[pdfid].metadata
is_internal = remote_is_internal_network(request)
......@@ -161,6 +163,7 @@ def send_pdf_file(request, pdffile):
pass
else:
return render_template('error.xml',
status=403,
error_hdr='Error',
error_text='This PDF file is available from the FAU internal network only',
theme=local.theme)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment