From 83ab9b0b3f26f2a26b8f59737a725119dee7c515 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Sun, 17 Nov 2024 23:00:31 +0100 Subject: keep get parameters over post request on move/remove increase character limit on password length form validation --- src/jwebmail/__init__.py | 2 +- src/jwebmail/render_mail.py | 6 +++--- src/jwebmail/templates/_bot_nav.html | 6 ++++++ src/jwebmail/webmail.py | 20 +++++++++++++++++--- 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src/jwebmail') diff --git a/src/jwebmail/__init__.py b/src/jwebmail/__init__.py index aecc817..67018ce 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.6.0.dev4" +__version__ = "2.6.0.dev5" csrf = CSRFProtect() diff --git a/src/jwebmail/render_mail.py b/src/jwebmail/render_mail.py index c36150d..7dc0824 100644 --- a/src/jwebmail/render_mail.py +++ b/src/jwebmail/render_mail.py @@ -11,7 +11,7 @@ def render_text_html(_subtype, _content, path): if path: url = url_for( "read", - folder=request.view_args.get("folder", ""), + folder=request.view_args.get("folder"), msgid=request.view_args["msgid"], format="raw", path=".".join(map(str, path)), @@ -19,7 +19,7 @@ def render_text_html(_subtype, _content, path): else: url = url_for( "read", - folder=request.view_args.get("folder", ""), + folder=request.view_args.get("folder"), msgid=request.view_args["msgid"], format="raw", ) @@ -78,7 +78,7 @@ def render_multipart(_subtype, content, path): ref_url = url_for( "read", - folder=request.view_args.get("folder", ""), + folder=request.view_args.get("folder"), msgid=request.view_args["msgid"], path=".".join(map(str, [*path, i])), format="raw", diff --git a/src/jwebmail/templates/_bot_nav.html b/src/jwebmail/templates/_bot_nav.html index 73a5170..2634151 100644 --- a/src/jwebmail/templates/_bot_nav.html +++ b/src/jwebmail/templates/_bot_nav.html @@ -9,6 +9,9 @@ {% if mail_folders|length > 1 %}
+ + +
@@ -32,6 +35,9 @@ method=POST class="is-pulled-left ml-2"> + + +
diff --git a/src/jwebmail/webmail.py b/src/jwebmail/webmail.py index 1b61daa..84cb6a7 100644 --- a/src/jwebmail/webmail.py +++ b/src/jwebmail/webmail.py @@ -36,7 +36,7 @@ from .render_mail import to_mime_type class LoginForm(FlaskForm): username = StringField(lazy_gettext("Username"), [validators.Email()]) password = PasswordField( - lazy_gettext("Password"), [validators.Length(min=5, max=35)] + lazy_gettext("Password"), [validators.Length(min=5, max=120)] ) @@ -186,6 +186,18 @@ def writemail(): return render_template("writemail.html", form=WriteForm()) +def _take_common_req_args(mapping): + print(mapping) + res = dict() + if mapping.get("sort"): + res["sort"] = mapping["sort"] + if mapping.get("per_page"): + res["per_page"] = mapping["per_page"] + if mapping.get("page"): + res["page"] = mapping["page"] + return res + + def move(folder=""): folders = get_read_mails_logged_in().folders() @@ -199,7 +211,8 @@ def move(folder=""): get_read_mails_logged_in().move(m, folder, to_folder) flash(gettext("succ_move")) - return redirect(url_for("displayheaders", folder=folder), 303) + args = _take_common_req_args(request.form) + return redirect(url_for("displayheaders", folder=folder, **args), 303) def remove(folder=""): @@ -220,7 +233,8 @@ def remove(folder=""): get_read_mails_logged_in().move(m, folder, "Trash") flash(gettext("succ_remove")) - return redirect(url_for("displayheaders", folder=folder), 303) + args = _take_common_req_args(request.form) + return redirect(url_for("displayheaders", folder=folder, **args), 303) def sendmail(): -- cgit v1.2.3