You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/04/10 19:54:53 UTC

(tooling-trusted-release) branch main updated: Only show projects for which users can actually create a new draft

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 16b6069  Only show projects for which users can actually create a new draft
16b6069 is described below

commit 16b6069062cb44d48c8e21ea7da7d6f8cb992d4c
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Thu Apr 10 20:54:15 2025 +0100

    Only show projects for which users can actually create a new draft
---
 atr/routes/draft.py |  3 ++-
 atr/user.py         | 10 +++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/atr/routes/draft.py b/atr/routes/draft.py
index ffebf23..633c897 100644
--- a/atr/routes/draft.py
+++ b/atr/routes/draft.py
@@ -41,6 +41,7 @@ import atr.db.models as models
 import atr.revision as revision
 import atr.routes as routes
 import atr.tasks.sbom as sbom
+import atr.user as user
 import atr.util as util
 
 if TYPE_CHECKING:
@@ -122,7 +123,7 @@ async def add(session: routes.CommitterSession) -> response.Response | str:
     """Show a page to allow the user to rsync files to candidate drafts."""
     # Do them outside of the template rendering call to ensure order
     # The user_candidate_drafts call can use cached results from user_projects
-    user_projects = await session.user_projects
+    user_projects = await user.projects(session.uid, committee_only=True)
     user_candidate_drafts = await session.user_candidate_drafts
     # Sort the project choices reverse chronologically by their creation date
     # This means that if the user added a project recently, it will be at the top of the list
diff --git a/atr/user.py b/atr/user.py
index 9ff79a1..5cc163f 100644
--- a/atr/user.py
+++ b/atr/user.py
@@ -59,7 +59,7 @@ def is_committee_member(committee: models.Committee | None, uid: str) -> bool:
     return any((member_uid == uid) for member_uid in committee.committee_members)
 
 
-async def projects(uid: str) -> list[models.Project]:
+async def projects(uid: str, committee_only: bool = False) -> list[models.Project]:
     user_projects: list[models.Project] = []
     async with db.session() as data:
         # Must have releases, because this is used in candidate_drafts
@@ -67,8 +67,12 @@ async def projects(uid: str) -> list[models.Project]:
         for p in projects:
             if p.committee is None:
                 continue
-            if (uid in p.committee.committee_members) or (uid in p.committee.committers):
-                user_projects.append(p)
+            if committee_only:
+                if uid in p.committee.committee_members:
+                    user_projects.append(p)
+            else:
+                if (uid in p.committee.committee_members) or (uid in p.committee.committers):
+                    user_projects.append(p)
     return user_projects
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org