diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-12-08 16:31:04 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-12-08 16:31:04 +0100 |
commit | 2f086f24d782144b304091e72c66ca75c006a98a (patch) | |
tree | ba64a7114b6e6a0f5a2d6a98adbe1ec6b642599d | |
parent | 57423db1e342b48c970b972a6f18e84e7a7b1a22 (diff) |
improve adding and retreiving url arguments from forms
-rw-r--r-- | src/jwebmail/__init__.py | 2 | ||||
-rw-r--r-- | src/jwebmail/templates/_bot_nav.html | 16 | ||||
-rw-r--r-- | src/jwebmail/webmail.py | 15 |
3 files changed, 10 insertions, 23 deletions
diff --git a/src/jwebmail/__init__.py b/src/jwebmail/__init__.py index 8b98e7a..86febf4 100644 --- a/src/jwebmail/__init__.py +++ b/src/jwebmail/__init__.py @@ -36,7 +36,7 @@ else: toml_read_file = dict(load=toml_load, text=True) -__version__ = "2.8.0.dev0" +__version__ = "2.8.1.dev0" csrf = CSRFProtect() diff --git a/src/jwebmail/templates/_bot_nav.html b/src/jwebmail/templates/_bot_nav.html index bd9e05a..d92d467 100644 --- a/src/jwebmail/templates/_bot_nav.html +++ b/src/jwebmail/templates/_bot_nav.html @@ -45,11 +45,9 @@ {% if mail_folders|length > 1 %} <form action="{{ url_for('move', folder=folder) }}" id="move-mail" class=is-pulled-left method=POST> <input type=hidden name=csrf_token value="{{ csrf_token() }}"> - <input type=hidden name=sort value="{{ request.args.sort }}"> - <input type=hidden name=search value="{{ request.args.search }}"> - <input type=hidden name=per_page value="{{ request.args.per_page }}"> - <input type=hidden name=page_bound value="{{ request.args.page_bound }}"> - <input type=hidden name=after_page value="{{ request.args.after_page }}"> + {% for k, v in request.args.items() if v %} + <input type=hidden name="{{ k }}" value="{{ v }}"> + {% endfor %} <div class="field has-addons"> <div class=control> <div class=select> @@ -73,11 +71,9 @@ method=POST class="is-pulled-left ml-2"> <input type=hidden name=csrf_token value="{{ csrf_token() }}"> - <input type=hidden name=sort value="{{ request.args.sort }}"> - <input type=hidden name=search value="{{ request.args.search }}"> - <input type=hidden name=per_page value="{{ request.args.per_page }}"> - <input type=hidden name=page_bound value="{{ request.args.page_bound }}"> - <input type=hidden name=after_page value="{{ request.args.after_page }}"> + {% for k, v in request.args.items() if v %} + <input type=hidden name="{{ k }}" value="{{ v }}"> + {% endfor %} <div class=control> <input id=remove type=submit class=button value="{{ gettext('Remove') }}"> </div> diff --git a/src/jwebmail/webmail.py b/src/jwebmail/webmail.py index 1b14af0..4ca1a67 100644 --- a/src/jwebmail/webmail.py +++ b/src/jwebmail/webmail.py @@ -202,18 +202,9 @@ def writemail(): def _take_common_req_args(mapping): - res = dict() - if mapping.get("sort"): - res["sort"] = mapping["sort"] - if mapping.get("search"): - res["search"] = mapping["search"] - if mapping.get("per_page"): - res["per_page"] = mapping["per_page"] - if mapping.get("page_bound"): - res["page_bound"] = mapping["page_bound"] - if mapping.get("after_page"): - res["after_page"] = mapping["after_page"] - return res + take = {"sort", "search", "per_page", "page_bound", "after_page"} + + return {k: v for k, v in mapping.items() if k in take} def move(folder=""): |