From 0b6006968e1d8c4b7e2333515fef0199cf920157 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Tue, 5 Dec 2017 11:26:43 +0530 Subject: [PATCH] manual: Download can serve either pdf or pdf.gz file Fixes the problem where an installation might not have a gzipped version of the manual (like the Plinth development VM for example). Signed-off-by: Joseph Nuthalapati Reviewed-by: Sunil Mohan Adapa --- plinth/modules/help/help.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plinth/modules/help/help.py b/plinth/modules/help/help.py index 83aea2154..6301b9d10 100644 --- a/plinth/modules/help/help.py +++ b/plinth/modules/help/help.py @@ -92,7 +92,13 @@ def download_manual(request): with gzip.open(os.path.join(cfg.doc_dir, manual_name), 'rb') as f: content = f.read() except IOError: - raise Http404('File {} does not exist.'.format(manual_name)) + try: + # pdf.gz doesn't exist. Try with .pdf + manual_name = manual_name.rpartition('.')[0] + with open(os.path.join(cfg.doc_dir, manual_name), 'rb') as f: + content = f.read() + except IOError: + raise Http404('File {} does not exist.'.format(manual_name)) return HttpResponse( ContentFile(content),