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/07/31 19:44:39 UTC

(tooling-trusted-release) branch main updated: Distinguish whether votes are binding in the form to cast a vote

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 d452043  Distinguish whether votes are binding in the form to cast a vote
d452043 is described below

commit d4520430593473032b971215e71aa9551627ba3a
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Thu Jul 31 20:43:40 2025 +0100

    Distinguish whether votes are binding in the form to cast a vote
---
 atr/routes/vote.py                                | 31 ++++++++++++++++++++---
 atr/templates/check-selected-candidate-forms.html |  6 -----
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/atr/routes/vote.py b/atr/routes/vote.py
index 6e1bb67..470dba0 100644
--- a/atr/routes/vote.py
+++ b/atr/routes/vote.py
@@ -29,6 +29,7 @@ import atr.models.sql as sql
 import atr.routes as routes
 import atr.routes.compose as compose
 import atr.routes.resolve as resolve
+import atr.storage as storage
 import atr.tasks.message as message
 import atr.util as util
 
@@ -50,8 +51,8 @@ _THREAD_URLS_FOR_DEVELOPMENT: Final[dict[str, str]] = {
 class CastVoteForm(forms.Typed):
     """Form for casting a vote."""
 
-    vote_value = forms.radio("Your vote", choices=[("+1", "+1 (Binding)"), ("0", "0"), ("-1", "-1 (Binding)")])
-    vote_comment = forms.textarea("Comment (optional)")
+    vote_value = forms.radio("Your vote")
+    vote_comment = forms.textarea("Comment (optional)", optional=True)
     submit = forms.submit("Submit vote")
 
 
@@ -89,10 +90,34 @@ async def selected(session: routes.CommitterSession, project_name: str, version_
         task_mid = resolve.task_mid_get(latest_vote_task)
         archive_url = await task_archive_url_cached(task_mid)
 
-    form = await CastVoteForm.create_form()
+    # Special form for the [ Resolve vote ] button, to make it POST
     hidden_form = await forms.Hidden.create_form()
     hidden_form.hidden_field.data = archive_url or ""
     hidden_form.submit.label.text = "Resolve vote"
+
+    if release.committee is None:
+        raise ValueError("Release has no committee")
+
+    # Form to cast a vote
+    form = await CastVoteForm.create_form()
+    async with storage.write(session.asf_uid) as write:
+        try:
+            if release.committee.is_podling:
+                _wacm = write.as_committee_member("incubator")
+            else:
+                _wacm = write.as_committee_member(release.committee.name)
+            potency = "Binding"
+        except storage.AccessError:
+            potency = "Non-binding"
+    forms.choices(
+        form.vote_value,
+        choices=[
+            ("+1", f"+1 ({potency})"),
+            ("0", "0"),
+            ("-1", f"-1 ({potency})"),
+        ],
+    )
+
     return await compose.check(
         session,
         release,
diff --git a/atr/templates/check-selected-candidate-forms.html b/atr/templates/check-selected-candidate-forms.html
index b3c5609..c4de407 100644
--- a/atr/templates/check-selected-candidate-forms.html
+++ b/atr/templates/check-selected-candidate-forms.html
@@ -4,12 +4,6 @@
 {% endif %}
 
 <h2>Cast your vote</h2>
-<div class="card bg-warning-subtle mb-3">
-  <div class="card-body p-3">
-    <i class="bi bi-exclamation-triangle me-1"></i>
-    <strong>TODO:</strong> We plan to make "Binding" dynamic based on membership. Currently this form always says "Binding" which is known to be wrong.
-  </div>
-</div>
 
 <form method="post"
       action="{{ as_url(routes.vote.selected_post, project_name=project_name, version_name=version_name) }}"


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