aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg
diff options
context:
space:
mode:
Diffstat (limited to 'webmentions_ssg')
-rw-r--r--webmentions_ssg/tasks/extension.py12
-rw-r--r--webmentions_ssg/views/sources.py22
-rw-r--r--webmentions_ssg/views/user.py5
3 files changed, 22 insertions, 17 deletions
diff --git a/webmentions_ssg/tasks/extension.py b/webmentions_ssg/tasks/extension.py
index a878e16..0ba87d8 100644
--- a/webmentions_ssg/tasks/extension.py
+++ b/webmentions_ssg/tasks/extension.py
@@ -185,9 +185,9 @@ class FlaskHuey:
handle.bind()
return handle
- def task[**P, R](
+ def task(
self, *task_args: Any, **task_kwargs: Any
- ) -> Callable[[Callable[P, R]], _DeferredTask]:
+ ) -> Callable[[Callable[..., Any]], _DeferredTask]:
"""Declare a task even before :meth:`init_app` has run.
:param task_args: Positional arguments for the Huey task decorator.
@@ -195,14 +195,14 @@ class FlaskHuey:
:returns: Decorator that registers and returns a lazily bound task.
"""
- def decorator(func: Callable[P, R]) -> _DeferredTask:
+ def decorator(func: Callable[..., Any]) -> _DeferredTask:
return self._register_task(func, task_args, task_kwargs, periodic=False)
return decorator
- def periodic_task[**P, R](
+ def periodic_task(
self, *task_args: Any, **task_kwargs: Any
- ) -> Callable[[Callable[P, R]], _DeferredTask]:
+ ) -> Callable[[Callable[..., Any]], _DeferredTask]:
"""Declare a periodic task against the current or next backend.
:param task_args: Positional arguments for the Huey periodic-task decorator.
@@ -210,7 +210,7 @@ class FlaskHuey:
:returns: Decorator that registers and returns a lazily bound periodic task.
"""
- def decorator(func: Callable[P, R]) -> _DeferredTask:
+ def decorator(func: Callable[..., Any]) -> _DeferredTask:
return self._register_task(func, task_args, task_kwargs, periodic=True)
return decorator
diff --git a/webmentions_ssg/views/sources.py b/webmentions_ssg/views/sources.py
index 1c9cc58..84b98fb 100644
--- a/webmentions_ssg/views/sources.py
+++ b/webmentions_ssg/views/sources.py
@@ -183,11 +183,10 @@ def rescan_sources() -> ResponseReturnValue:
manual_scan_sources()
flash("Source rescan queued.", "success")
- query_args: dict[str, str | int] = dict(filters)
page = request.args.get("page", 1, type=int)
- if page > 1:
- query_args["page"] = page
- return redirect(url_for("webmentions.source_list", **query_args))
+ return redirect(
+ url_for("webmentions.source_list", page=page if page > 1 else None, **filters)
+ )
@webmentions_bp.route("/sources/<uuid:source_uuid>")
@@ -256,11 +255,14 @@ def resend_webmention(
flash(f"Webmention {webmention.uuid} queued for resend.", "success")
- detail_args: dict[str, str | int] = dict(filters)
- for name in ("page", "source_page"):
- page = request.args.get(name, 1, type=int)
- if page > 1:
- detail_args[name] = page
+ page = request.args.get("page", 1, type=int)
+ source_page = request.args.get("source_page", 1, type=int)
return redirect(
- url_for("webmentions.source_detail", source_uuid=source_uuid, **detail_args)
+ url_for(
+ "webmentions.source_detail",
+ source_uuid=source_uuid,
+ page=page if page > 1 else None,
+ source_page=source_page if source_page > 1 else None,
+ **filters,
+ )
)
diff --git a/webmentions_ssg/views/user.py b/webmentions_ssg/views/user.py
index 4675ade..ec253c4 100644
--- a/webmentions_ssg/views/user.py
+++ b/webmentions_ssg/views/user.py
@@ -25,7 +25,10 @@ def user_page() -> ResponseReturnValue:
if form.validate_on_submit():
user = cast(User, current_user._get_current_object())
if not user.check_password(form.current_password.data or ""):
- form.current_password.errors.append("Current password is incorrect.")
+ form.current_password.errors = [
+ *form.current_password.errors,
+ "Current password is incorrect.",
+ ]
else:
user.password = form.new_password.data or ""
db.session.commit()