summaryrefslogtreecommitdiff
path: root/ishtar_common/views_item.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-02-15 17:43:11 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-04-16 16:41:51 +0200
commit792f32ef4068a5c4265e1b6dfadb5683cfe2ed73 (patch)
tree6639daca38484dcdcf7b1d107cbc8bae99fbf082 /ishtar_common/views_item.py
parentc61701ec15bf7b54d49ea0b6cd0fe8ab58bcfabf (diff)
downloadIshtar-792f32ef4068a5c4265e1b6dfadb5683cfe2ed73.tar.bz2
Ishtar-792f32ef4068a5c4265e1b6dfadb5683cfe2ed73.zip
✨ sheets: manage specific sheets for specific modules
Diffstat (limited to 'ishtar_common/views_item.py')
-rw-r--r--ishtar_common/views_item.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index 735ccf2e1..ed2fb07ea 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -363,6 +363,11 @@ def show_item(model, name, extra_dct=None, model_for_perms=None, callback=None):
"/".join(reverse("show-" + name, args=["0", ""]).split("/")[:-2]) + "/"
)
profile = get_current_profile()
+ sheet_name = name
+ for profile_key, alt_name in model.SHEET_ALTERNATIVES:
+ if getattr(profile, profile_key):
+ sheet_name = alt_name
+ break
dct["PROFILE"] = profile
dct["CURRENCY"] = profile.currency
dct["ENCODING"] = settings.ENCODING
@@ -454,7 +459,7 @@ def show_item(model, name, extra_dct=None, model_for_perms=None, callback=None):
else:
filename = item.associated_filename
if doc_type == "odt" and settings.ODT_TEMPLATE:
- tpl = loader.get_template("ishtar/sheet_%s.html" % name)
+ tpl = loader.get_template(f"ishtar/sheet_{sheet_name}.html")
context_instance["output"] = "ODT"
content = tpl.render(context_instance, request)
tidy_options = {
@@ -503,7 +508,7 @@ def show_item(model, name, extra_dct=None, model_for_perms=None, callback=None):
elif doc_type == "pdf":
base_url = "/".join(request.build_absolute_uri().split("/")[0:3])
- tpl = loader.get_template("ishtar/sheet_%s_pdf.html" % name)
+ tpl = loader.get_template(f"ishtar/sheet_{sheet_name}_pdf.html")
context_instance["output"] = "PDF"
html = tpl.render(context_instance, request)
font_config = FontConfiguration()
@@ -530,7 +535,7 @@ def show_item(model, name, extra_dct=None, model_for_perms=None, callback=None):
response["Content-Disposition"] = "attachment; filename=%s.pdf" % filename
return response
else:
- tpl = loader.get_template("ishtar/sheet_%s_window.html" % name)
+ tpl = loader.get_template(f"ishtar/sheet_{sheet_name}_window.html")
content = tpl.render(context_instance, request)
return HttpResponse(content, content_type="application/xhtml")