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 2026/02/03 15:36:14 UTC

(tooling-trusted-releases) branch sbp updated (c3ffe8e -> eb43027)

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a change to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


    from c3ffe8e  Wait for asyncssh cleanup tasks to run, to avoid warnings
     add 6bae4fb  Binding vote noted in email #616
     new eb43027  Add and use a shared function to decide whether a vote is binding

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 atr/get/vote.py             |  16 +---
 atr/post/vote.py            |   8 +-
 atr/shared/vote.py          |  20 +++++
 atr/storage/writers/vote.py |  44 ++++++++--
 tests/unit/test_vote.py     | 201 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 267 insertions(+), 22 deletions(-)
 create mode 100644 tests/unit/test_vote.py


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


(tooling-trusted-releases) 01/01: Add and use a shared function to decide whether a vote is binding

Posted by sb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git

commit eb4302711f00c27e64462c17aefa3f47cb5de299
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Tue Feb 3 15:31:39 2026 +0000

    Add and use a shared function to decide whether a vote is binding
---
 atr/get/vote.py    | 16 +---------------
 atr/post/vote.py   | 14 +-------------
 atr/shared/vote.py | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/atr/get/vote.py b/atr/get/vote.py
index f6cbf6a..9197afd 100644
--- a/atr/get/vote.py
+++ b/atr/get/vote.py
@@ -497,22 +497,8 @@ async def _render_vote_authenticated(
     if session is None:
         raise ValueError("Session required for authenticated vote")
 
-    # Determine vote potency based on user category
-    # For podlings, incubator PMC membership grants binding status always
-    # This breaks the test route though
     is_pmc_member = user_category in (UserCategory.PMC_MEMBER, UserCategory.PMC_MEMBER_RM)
-
-    if release.committee.is_podling:
-        async with storage.write() as write:
-            try:
-                _wacm = write.as_committee_member("incubator")
-                is_binding = True
-            except storage.AccessError:
-                is_binding = False
-        binding_committee = "Incubator"
-    else:
-        is_binding = is_pmc_member
-        binding_committee = release.committee.display_name
+    is_binding, binding_committee = await shared.vote.is_binding(release.committee, is_pmc_member)
 
     potency = "Binding" if is_binding else "Non-binding"
     if is_binding:
diff --git a/atr/post/vote.py b/atr/post/vote.py
index 324a271..bed25c7 100644
--- a/atr/post/vote.py
+++ b/atr/post/vote.py
@@ -41,20 +41,8 @@ async def selected_post(
     vote = cast_vote_form.decision
     comment = cast_vote_form.comment
 
-    # Determine if the vote is binding based on committee membership
-    # This logic mirrors atr/get/vote.py _render_vote_authenticated()
     is_pmc_member = user.is_committee_member(release.committee, session.uid)
-
-    if release.committee.is_podling:
-        # For podlings, Incubator PMC membership grants binding status
-        async with storage.write() as write:
-            try:
-                _wacm = write.as_committee_member("incubator")
-                is_binding = True
-            except storage.AccessError:
-                is_binding = False
-    else:
-        is_binding = is_pmc_member
+    is_binding, _binding_committee = await shared.vote.is_binding(release.committee, is_pmc_member)
 
     async with storage.write_as_committee_participant(release.committee.name) as wacm:
         email_recipient, error_message = await wacm.vote.send_user_vote(
diff --git a/atr/shared/vote.py b/atr/shared/vote.py
index fb30afb..e634293 100644
--- a/atr/shared/vote.py
+++ b/atr/shared/vote.py
@@ -18,8 +18,28 @@
 from typing import Literal
 
 import atr.form as form
+import atr.models.sql as sql
+import atr.storage as storage
 
 
 class CastVoteForm(form.Form):
     decision: Literal["+1", "0", "-1"] = form.label("Your vote", widget=form.Widget.CUSTOM)
     comment: str = form.label("Comment (optional)", widget=form.Widget.TEXTAREA)
+
+
+async def is_binding(
+    committee: sql.Committee,
+    is_pmc_member: bool,
+) -> tuple[bool, str]:
+    if committee.is_podling:
+        async with storage.write() as write:
+            try:
+                _wacm = write.as_committee_member("incubator")
+                is_binding = True
+            except storage.AccessError:
+                is_binding = False
+        binding_committee = "Incubator"
+    else:
+        is_binding = is_pmc_member
+        binding_committee = committee.display_name
+    return is_binding, binding_committee


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