simpler fail if logo is not found

This commit is contained in:
Spitap
2023-02-18 11:22:27 +01:00
parent ec4ac89e8e
commit faf718d7a0
2 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -62,7 +62,9 @@ def credentials(account, password):
buff = BytesIO()
doc = SimpleDocTemplate(buff, pagesize=A4)
story = []
story.append(resized_image(lib.get_document_logo(), 8*cm))
logo = lib.get_document_logo()
if logo is not None:
story.append(resized_image(logo, 8*cm))
story.append(Spacer(1, 1 * cm))
story.append(Paragraph(conf["title"], styles["Title"]))
story.append(Spacer(1, 1 * cm))
+4 -1
View File
@@ -96,6 +96,9 @@ def get_document_logo():
logo = settings.MODOBOA_CUSTOM_LOGO
logo = os.path.join(settings.MEDIA_ROOT, os.path.basename(logo))
except AttributeError:
logo = os.path.join(settings.STATIC_ROOT, "css/modoboa.png")
try:
logo = os.path.join(settings.STATIC_ROOT, "css/modoboa.png")
except OSError:
return None
finally:
return logo