This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/main by this push:
new ac4dcf4 Fix some function ordering and remove unused code
ac4dcf4 is described below
commit ac4dcf441e41daa720c6d835460d359cac9c75e0
Author: Sean B. Palmer <[email protected]>
AuthorDate: Wed Dec 31 18:50:35 2025 +0000
Fix some function ordering and remove unused code
---
atr/api/__init__.py | 15 ---------------
atr/blueprints/admin.py | 24 ++++++++++++------------
atr/blueprints/get.py | 14 +++++++-------
atr/blueprints/post.py | 14 +++++++-------
4 files changed, 26 insertions(+), 41 deletions(-)
diff --git a/atr/api/__init__.py b/atr/api/__init__.py
index ba2b740..93348be 100644
--- a/atr/api/__init__.py
+++ b/atr/api/__init__.py
@@ -1269,21 +1269,6 @@ async def vote_tabulate(data:
models.api.VoteTabulateArgs) -> DictResponse:
).model_dump(), 200
-def _committee_member_or_admin(committee: sql.Committee, asf_uid: str) -> None:
- if not (user.is_committee_member(committee, asf_uid) or
user.is_admin(asf_uid)):
- raise exceptions.Forbidden("You do not have permission to perform this
action")
-
-
-# @db.session_function
-# async def _get_pat(data: db.Session, uid: str, token_hash: str) ->
sql.PersonalAccessToken | None:
-# return await data.query_one_or_none(
-# sqlmodel.select(sql.PersonalAccessToken).where(
-# sql.PersonalAccessToken.asfuid == uid,
-# sql.PersonalAccessToken.token_hash == token_hash,
-# )
-# )
-
-
def _jwt_asf_uid() -> str:
claims = getattr(quart.g, "jwt_claims", {})
asf_uid = claims.get("sub")
diff --git a/atr/blueprints/admin.py b/atr/blueprints/admin.py
index c3318d3..ca58b77 100644
--- a/atr/blueprints/admin.py
+++ b/atr/blueprints/admin.py
@@ -33,18 +33,6 @@ _BLUEPRINT_NAME = "admin_blueprint"
_BLUEPRINT = quart.Blueprint(_BLUEPRINT_NAME, __name__, url_prefix="/admin",
template_folder="../admin/templates")
-@_BLUEPRINT.before_request
-async def _check_admin_access() -> None:
- web_session = await asfquart.session.read()
- if web_session is None:
- raise base.ASFQuartException("Not authenticated", errorcode=401)
-
- if web_session.uid not in user.get_admin_users():
- raise base.ASFQuartException("You are not authorized to access the
admin interface", errorcode=403)
-
- quart.g.session = web.Committer(web_session)
-
-
def empty() -> Callable[[Callable[..., Awaitable[Any]]], Callable[...,
Awaitable[Any]]]:
def decorator(func: Callable[..., Awaitable[Any]]) -> Callable[...,
Awaitable[Any]]:
async def wrapper(session: web.Committer, *args: Any, **kwargs: Any)
-> Any:
@@ -144,3 +132,15 @@ def register(app: base.QuartApp) -> tuple[ModuleType,
list[str]]:
app.register_blueprint(_BLUEPRINT)
return admin, []
+
+
+@_BLUEPRINT.before_request
+async def _check_admin_access() -> None:
+ web_session = await asfquart.session.read()
+ if web_session is None:
+ raise base.ASFQuartException("Not authenticated", errorcode=401)
+
+ if web_session.uid not in user.get_admin_users():
+ raise base.ASFQuartException("You are not authorized to access the
admin interface", errorcode=403)
+
+ quart.g.session = web.Committer(web_session)
diff --git a/atr/blueprints/get.py b/atr/blueprints/get.py
index eb05ac9..396b5a3 100644
--- a/atr/blueprints/get.py
+++ b/atr/blueprints/get.py
@@ -33,13 +33,6 @@ _BLUEPRINT = quart.Blueprint(_BLUEPRINT_NAME, __name__)
_routes: list[str] = []
-def register(app: base.QuartApp) -> tuple[ModuleType, list[str]]:
- import atr.get as get
-
- app.register_blueprint(_BLUEPRINT)
- return get, _routes
-
-
def committer(path: str) -> Callable[[web.CommitterRouteFunction[Any]],
web.RouteFunction[Any]]:
def decorator(func: web.CommitterRouteFunction[Any]) ->
web.RouteFunction[Any]:
async def wrapper(*args: Any, **kwargs: Any) -> Any:
@@ -97,3 +90,10 @@ def public(path: str) -> Callable[[Callable[...,
Awaitable[Any]]], web.RouteFunc
return wrapper
return decorator
+
+
+def register(app: base.QuartApp) -> tuple[ModuleType, list[str]]:
+ import atr.get as get
+
+ app.register_blueprint(_BLUEPRINT)
+ return get, _routes
diff --git a/atr/blueprints/post.py b/atr/blueprints/post.py
index 9acbd26..e232b29 100644
--- a/atr/blueprints/post.py
+++ b/atr/blueprints/post.py
@@ -36,13 +36,6 @@ _BLUEPRINT = quart.Blueprint(_BLUEPRINT_NAME, __name__)
_routes: list[str] = []
-def register(app: base.QuartApp) -> tuple[ModuleType, list[str]]:
- import atr.post as post
-
- app.register_blueprint(_BLUEPRINT)
- return post, _routes
-
-
def committer(path: str) -> Callable[[web.CommitterRouteFunction[Any]],
web.RouteFunction[Any]]:
def decorator(func: web.CommitterRouteFunction[Any]) ->
web.RouteFunction[Any]:
async def wrapper(*args: Any, **kwargs: Any) -> Any:
@@ -197,3 +190,10 @@ def public(path: str) -> Callable[[Callable[...,
Awaitable[Any]]], web.RouteFunc
return wrapper
return decorator
+
+
+def register(app: base.QuartApp) -> tuple[ModuleType, list[str]]:
+ import atr.post as post
+
+ app.register_blueprint(_BLUEPRINT)
+ return post, _routes
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]