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 <[email protected]> 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: [email protected] For additional commands, e-mail: [email protected]
