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 0da52ba Add a property to get the admin status of committer sessions
0da52ba is described below
commit 0da52ba203ee73caf3e615f48820707e65be8e87
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Jan 23 16:57:45 2026 +0000
Add a property to get the admin status of committer sessions
---
atr/db/interaction.py | 2 +-
atr/get/keys.py | 3 +--
atr/get/projects.py | 2 +-
atr/get/vote.py | 2 +-
atr/web.py | 8 ++++++--
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/atr/db/interaction.py b/atr/db/interaction.py
index f951eef..35e2f30 100644
--- a/atr/db/interaction.py
+++ b/atr/db/interaction.py
@@ -274,7 +274,7 @@ async def release_ready_for_vote(
if await has_failing_checks(release, revision, caller_data=data):
return "This release candidate draft has errors. Please fix the
errors before starting a vote."
- if not (user.is_committee_member(committee, session.uid) or
user.is_admin(session.uid)):
+ if not (user.is_committee_member(committee, session.uid) or
session.is_admin):
return "You must be on the PMC of this project to start a vote"
has_files = await util.has_files(release)
diff --git a/atr/get/keys.py b/atr/get/keys.py
index 1b14e2a..16da02d 100644
--- a/atr/get/keys.py
+++ b/atr/get/keys.py
@@ -30,7 +30,6 @@ import atr.post as post
import atr.shared as shared
import atr.storage as storage
import atr.template as template
-import atr.user as user
import atr.util as util
import atr.web as web
@@ -326,7 +325,7 @@ async def _key_and_is_owner(
key_committee_names = {c.name for c in key.committees}
if user_affiliations.intersection(key_committee_names):
authorised = True
- elif user.is_admin(session.uid):
+ elif session.is_admin:
authorised = True
if not authorised:
diff --git a/atr/get/projects.py b/atr/get/projects.py
index 0d453cb..6db986b 100644
--- a/atr/get/projects.py
+++ b/atr/get/projects.py
@@ -141,7 +141,7 @@ async def view(session: web.Committer, name: str) ->
web.WerkzeugResponse | str:
).demand(base.ASFQuartException(f"Project {name} not found",
errorcode=404))
is_committee_member = project.committee and
(user.is_committee_member(project.committee, session.uid))
- is_privileged = user.is_admin(session.uid)
+ is_privileged = session.is_admin
can_edit = is_committee_member or is_privileged
candidate_drafts = await interaction.candidate_drafts(project)
diff --git a/atr/get/vote.py b/atr/get/vote.py
index b243e25..f6cbf6a 100644
--- a/atr/get/vote.py
+++ b/atr/get/vote.py
@@ -79,7 +79,7 @@ async def category_and_release(
if session is None:
return UserCategory.UNAUTHENTICATED, release, latest_vote_task
- is_pmc_member = (user.is_committee_member(release.committee, session.uid))
or (user.is_admin(session.uid))
+ is_pmc_member = (user.is_committee_member(release.committee, session.uid))
or session.is_admin
is_release_manager = (vote_initiator_uid is not None) and (session.uid ==
vote_initiator_uid)
if is_pmc_member and is_release_manager:
diff --git a/atr/web.py b/atr/web.py
index 33b7cff..bb075b1 100644
--- a/atr/web.py
+++ b/atr/web.py
@@ -82,9 +82,13 @@ class Committer:
def app_host(self) -> str:
return config.get().APP_HOST
+ @property
+ def is_admin(self) -> bool:
+ return user.is_admin(self.uid)
+
async def check_access(self, project_name: str) -> None:
if not any((p.name == project_name) for p in (await
self.user_projects)):
- if user.is_admin(self.uid):
+ if self.is_admin:
# Admins can view all projects
# But we must warn them when the project is not one of their
own
# TODO: This code is difficult to test locally
@@ -95,7 +99,7 @@ class Committer:
async def check_access_committee(self, committee_name: str) -> None:
if committee_name not in self.committees:
- if user.is_admin(self.uid):
+ if self.is_admin:
# Admins can view all committees
# But we must warn them when the committee is not one of their
own
# TODO: As above, this code is difficult to test locally
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]