From: Christian Heller Date: Mon, 27 Jan 2025 07:16:51 +0000 (+0100) Subject: On reload and save button use, always redirect to where we're coming from. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/static/te"st.html?a=commitdiff_plain;p=plomledger On reload and save button use, always redirect to where we're coming from. --- diff --git a/ledger.py b/ledger.py index 7a62924..2627237 100755 --- a/ledger.py +++ b/ledger.py @@ -251,15 +251,12 @@ class Handler(PlomHttpHandler): def do_POST(self) -> None: # pylint: disable=invalid-name,missing-function-docstring - redir_path = Path('/') if self.pagename.startswith('edit_'): id_ = int(self.path_toks[2]) - redir_path = redir_path.joinpath(self.pagename).joinpath(str(id_)) - if self.pagename == 'file': - if 'reload' in self.postvars.as_dict: - self.server.load() - elif 'save' in self.postvars.as_dict: - self.server.save() + if 'reload_file' in self.postvars.as_dict: + self.server.load() + elif 'save_file' in self.postvars.as_dict: + self.server.save() elif self.pagename == 'edit_structured': if self.postvars.first('apply'): line_keys = self.postvars.keys_prefixed('line_') @@ -289,6 +286,7 @@ class Handler(PlomHttpHandler): data += f' {input_}' new_dat_lines += [ DatLine(f'{data} ; {comment}' if comment else data)] + # pylint: disable=possibly-used-before-assignment self.server.rewrite_booking(id_, new_dat_lines) elif self.pagename == 'edit_raw': if self.postvars.first('apply'): @@ -296,11 +294,11 @@ class Handler(PlomHttpHandler): DatLine(line) for line in self.postvars.first('booking').splitlines()] self.server.rewrite_booking(id_, new_dat_lines) - self.redirect(redir_path) + self.redirect(Path(self.path)) def do_GET(self) -> None: # pylint: disable=invalid-name,missing-function-docstring - ctx = {'tainted': self.server.tainted} + ctx = {'tainted': self.server.tainted, 'path': self.path} if self.pagename == 'booking' or self.pagename.startswith('edit_'): ctx['id'] = int(self.path_toks[2]) if self.pagename == 'balance': diff --git a/templates/_base.tmpl b/templates/_base.tmpl index 0ec782d..af5070c 100644 --- a/templates/_base.tmpl +++ b/templates/_base.tmpl @@ -16,8 +16,8 @@ span.warning, table.warning tbody tr td, tr.warning td { background-color: #ff88 -
-ledger structured / raw · balance · {% if tainted %} · unsaved changes: {% endif %} + +ledger structured / raw · balance · {% if tainted %} · unsaved changes: {% endif %}

{% block content %}{% endblock %}