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_')
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'):
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':
</style>
</head>
<body>
-<form action="/file" method="POST">
-ledger <a href="/ledger_structured">structured</a> / <a href="/ledger_raw">raw</a> · <a href="/balance">balance</a> · <input type="submit" name="reload" value="reload" />{% if tainted %} · <span class="warning">unsaved changes: <input type="submit" name="save" value="save"></span>{% endif %}
+<form action="{{path}}" method="POST">
+ledger <a href="/ledger_structured">structured</a> / <a href="/ledger_raw">raw</a> · <a href="/balance">balance</a> · <input type="submit" name="reload_file" value="reload" />{% if tainted %} · <span class="warning">unsaved changes: <input type="submit" name="save_file" value="save"></span>{% endif %}
</form>
<hr />
{% block content %}{% endblock %}