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

tn 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 398b84b  use bootstrap validation for vote policy fields
398b84b is described below

commit 398b84b758e7e75949915d80b8710e3f44e35c24
Author: Thomas Neidhart <[email protected]>
AuthorDate: Tue Apr 1 17:09:04 2025 +0200

    use bootstrap validation for vote policy fields
---
 atr/routes/projects.py              |  6 +++++-
 atr/templates/project-view.html     |  2 +-
 atr/templates/vote-policy-form.html | 16 ++++++++++------
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/atr/routes/projects.py b/atr/routes/projects.py
index af4207c..169ee68 100644
--- a/atr/routes/projects.py
+++ b/atr/routes/projects.py
@@ -68,7 +68,11 @@ class VotePolicyForm(util.QuartFormTyped):
         min_entries=1,
     )
     min_hours = wtforms.IntegerField(
-        "Minimum Voting Period:", widget=wtforms.widgets.NumberInput(min=0, 
max=144), default=72
+        "Minimum Voting Period:",
+        validators=[
+            wtforms.validators.NumberRange(min=0, max=144, message="Voting 
period must be between 0h and 144h")
+        ],
+        default=72,
     )
     manual_vote = wtforms.BooleanField("Voting Process:")
     release_checklist = wtforms.StringField("Release Checklist:", 
widget=wtforms.widgets.TextArea())
diff --git a/atr/templates/project-view.html b/atr/templates/project-view.html
index 0b4ab6a..686a926 100644
--- a/atr/templates/project-view.html
+++ b/atr/templates/project-view.html
@@ -131,7 +131,7 @@
             <table class="table mb-0">
               <tbody>
                 <tr>
-                  <th class="border-0">Email</th>
+                  <th class="border-0 w-25">Email</th>
                   <td class="text-break border-0">
                     <a href="mailto:{{ vp.mailto_addresses[0] }}">{{ 
vp.mailto_addresses[0] }}</a>
                   </td>
diff --git a/atr/templates/vote-policy-form.html 
b/atr/templates/vote-policy-form.html
index 251450d..5441cf5 100644
--- a/atr/templates/vote-policy-form.html
+++ b/atr/templates/vote-policy-form.html
@@ -1,7 +1,8 @@
 
 <form method="post"
       enctype="multipart/form-data"
-      class="striking py-4 px-5">
+      class="striking py-4 px-5 needs-validation"
+      novalidate>
   <input type="hidden" name="form_type" value="single" />
   {{ form.hidden_tag() }}
   <div class="mb-3 pb-3 row border-bottom">
@@ -15,10 +16,10 @@
     <label for="{{ form.mailto_addresses.entries[0].id }}"
            class="col-sm-3 col-form-label text-sm-end">{{ 
form.mailto_addresses.entries[0].label.text }}</label>
     <div class="col-sm-8">
-      <div>{{ form.mailto_addresses.entries[0](size=30, class_="form-control") 
}}</div>
-      {% if form.mailto_addresses.entries[0].errors -%}
-        <span class="error-message">{{ 
form.mailto_addresses.entries[0].errors[0] }}</span>
-      {%- endif %}
+      {{ form.mailto_addresses.entries[0](size=30, class_="form-control" + (" 
is-invalid" if form.mailto_addresses[0].errors else "")) }}
+      {% if form.mailto_addresses[0].errors %}
+        {% for error in form.mailto_addresses[0].errors %}<div 
class="invalid-feedback">{{ error }}</div>{% endfor %}
+      {% endif %}
     </div>
   </div>
 
@@ -37,8 +38,11 @@
     <label for="{{ form.min_hours.id }}"
            class="col-sm-3 col-form-label text-sm-end">{{ 
form.min_hours.label.text }}</label>
     <div class="col-sm-8">
-      {{ form.min_hours(class_="form-control") }}
+      {{ form.min_hours(class_="form-control" + (" is-invalid" if 
form.min_hours.errors else "") ) }}
       <span id="min_hours-help" class="form-text text-muted">The minimum time 
to run the vote. If set to 0 then wait until 3 +1 votes and more +1 than 
-1.</span>
+      {% if form.min_hours.errors %}
+        {% for error in form.min_hours.errors %}<div 
class="invalid-feedback">{{ error }}</div>{% endfor %}
+      {% endif %}
     </div>
   </div>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to