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-release.git
The following commit(s) were added to refs/heads/main by this push:
new 0a6a549 Use the storage interface to obtain membership and
participation lists
0a6a549 is described below
commit 0a6a5497f763b98f148b75a4b3dd02b48860d9ba
Author: Sean B. Palmer <[email protected]>
AuthorDate: Wed Jul 23 14:49:10 2025 +0100
Use the storage interface to obtain membership and participation lists
---
atr/routes/__init__.py | 2 +-
atr/routes/keys.py | 12 ++++--------
atr/storage/__init__.py | 20 ++++++++++++++++++++
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/atr/routes/__init__.py b/atr/routes/__init__.py
index a32a850..18e0142 100644
--- a/atr/routes/__init__.py
+++ b/atr/routes/__init__.py
@@ -282,7 +282,7 @@ class CommitterSession:
async def user_projects(self) -> list[sql.Project]:
if self._projects is None:
self._projects = await user.projects(self.uid)
- return self._projects
+ return self._projects[:]
class FlashError(RuntimeError): ...
diff --git a/atr/routes/keys.py b/atr/routes/keys.py
index 0d8505f..f899a7e 100644
--- a/atr/routes/keys.py
+++ b/atr/routes/keys.py
@@ -126,14 +126,10 @@ async def add(session: routes.CommitterSession) -> str:
"""Add a new public signing key to the user's account."""
key_info = None
- # Get committees for all projects the user is a member of
- async with db.session() as data:
- project_list = session.committees + session.projects
- user_committees = await data.committee(name_in=project_list).all()
+ async with storage.write(session.uid) as write:
+ participant_of_committees = await write.participant_of_committees()
- committee_choices = [
- (c.name, c.display_name or c.name) for c in user_committees if (not
util.committee_is_standing(c.name))
- ]
+ committee_choices = [(c.name, c.display_name or c.name) for c in
participant_of_committees]
class AddOpenPGPKeyForm(util.QuartFormTyped):
public_key = wtforms.TextAreaField(
@@ -192,7 +188,7 @@ async def add(session: routes.CommitterSession) -> str:
return await template.render(
"keys-add.html",
asf_id=session.uid,
- user_committees=user_committees,
+ user_committees=participant_of_committees,
form=form,
key_info=key_info,
algorithms=routes.algorithms,
diff --git a/atr/storage/__init__.py b/atr/storage/__init__.py
index e6517fb..8e9ea6e 100644
--- a/atr/storage/__init__.py
+++ b/atr/storage/__init__.py
@@ -26,8 +26,10 @@ if TYPE_CHECKING:
from collections.abc import AsyncGenerator
import atr.db as db
+import atr.models.sql as sql
import atr.storage.types as types
import atr.storage.writers as writers
+import atr.util as util
VALIDATE_AT_RUNTIME: Final[bool] = True
@@ -269,6 +271,24 @@ class Write:
return types.OutcomeException(e)
return types.OutcomeResult(wacm)
+ @property
+ def member_of(self) -> set[str]:
+ return self.__member_of.copy()
+
+ async def member_of_committees(self) -> list[sql.Committee]:
+ committees = list(await
self.__data.committee(name_in=list(self.__member_of)).all())
+ committees.sort(key=lambda c: c.name)
+ return [c for c in committees if (not
util.committee_is_standing(c.name))]
+
+ @property
+ def participant_of(self) -> set[str]:
+ return self.__participant_of.copy()
+
+ async def participant_of_committees(self) -> list[sql.Committee]:
+ committees = list(await
self.__data.committee(name_in=list(self.__participant_of)).all())
+ committees.sort(key=lambda c: c.name)
+ return [c for c in committees if (not
util.committee_is_standing(c.name))]
+
# Context managers
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]