You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2026/02/20 08:07:41 UTC
(steve) branch trunk updated (572d239 -> 92843a9)
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
from 572d239 feat: add set_open_at and set_close_at methods to Election class
new e805ed5 feat: add upcoming elections section to voter page
new c4f7cd8 feat: add upcoming_to_pid method and q_upcoming_to_me query
new 92843a9 fix: correct undefined name 'iid' in IssueNotFound.__str__
The 3 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:
v3/TODO.md | 9 ++-------
v3/queries.yaml | 23 ++++++++++++++++++++++
v3/server/pages.py | 3 ++-
v3/server/templates/voter.ezt | 46 +++++++++++++++++++++++++++++++++++++++++++
v3/steve/election.py | 14 ++++++++++++-
5 files changed, 86 insertions(+), 9 deletions(-)
(steve) 02/03: feat: add upcoming_to_pid method and q_upcoming_to_me query
Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit c4f7cd8fd41f955e2544f483daa4a16f8c418b8c
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 20 02:03:55 2026 -0600
feat: add upcoming_to_pid method and q_upcoming_to_me query
Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
v3/queries.yaml | 23 +++++++++++++++++++++++
v3/steve/election.py | 14 +++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/v3/queries.yaml b/v3/queries.yaml
index 363356e..01c831d 100644
--- a/v3/queries.yaml
+++ b/v3/queries.yaml
@@ -135,6 +135,29 @@ election:
owner_pid, (opened_key IS NOT NULL) AS is_opened
FROM election WHERE owner_pid = ?
+ # Returns all editable elections for voting by the specified person (PID).
+ # An election is included if:
+ # - The person has mayvote entries for any issues in the election
+ # - The election is editable (salt IS NULL)
+ #
+ # Uses LEFT JOIN to person table to fetch the owner's name for display,
+ # ensuring elections are still returned even if the owner_pid does not
+ # exist in the person table (in which case owner_name will be NULL).
+ #
+ # Returns: eid, title, open_at, close_at, issue_count, owner_name
+ q_upcoming_to_me: |
+ SELECT e.eid, e.title, e.open_at, e.close_at,
+ COUNT(i.iid) AS issue_count,
+ p.name AS owner_name
+ FROM mayvote m
+ JOIN issue i ON m.iid = i.iid
+ JOIN election e ON i.eid = e.eid
+ LEFT JOIN person p ON e.owner_pid = p.pid
+ WHERE m.pid = ?
+ AND e.salt IS NULL
+ GROUP BY e.eid
+ ORDER BY e._ROWID_
+
person:
c_add_person: |
diff --git a/v3/steve/election.py b/v3/steve/election.py
index 0b06f35..8d74d3f 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -484,6 +484,18 @@ class Election:
)
return [row for row in db.q_owned.fetchall()]
+ @classmethod
+ def upcoming_to_pid(cls, db_fname, pid):
+ "List of editable elections for PID to vote upon."
+
+ db = cls.open_database(db_fname)
+
+ # Run the generator to get all rows. Returned as EasyDicts.
+ db.q_upcoming_to_me.perform(
+ pid,
+ )
+ return [row for row in db.q_upcoming_to_me.fetchall()]
+
def set_open_at(self, timestamp):
"Set the open_at timestamp for this Election."
self.c_set_open_at.perform(timestamp, self.eid)
@@ -527,4 +539,4 @@ class IssueNotFound(Exception):
super().__init__(str(self))
def __str__(self):
- return f'Issue[I:{self.iid}] not found'
+ return f'Issue[I:{iid}] not found'
(steve) 01/03: feat: add upcoming elections section to voter page
Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit e805ed5db52eac09b80fe9f144cb6798013cbcc5
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 20 02:00:19 2026 -0600
feat: add upcoming elections section to voter page
Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
v3/TODO.md | 9 ++-------
v3/server/pages.py | 3 ++-
v3/server/templates/voter.ezt | 46 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/v3/TODO.md b/v3/TODO.md
index d062c76..ddbd3ee 100644
--- a/v3/TODO.md
+++ b/v3/TODO.md
@@ -7,15 +7,10 @@ Based on a review of `v3/server/pages.py` (and related templates like `voter.ezt
- **Impact**: Users won't be able to save dates via the UI, breaking the intended workflow.
- **Resolution**: Added the two endpoints with a refactored helper function `_set_election_date` to handle common logic (auth, JSON parsing, validation, setting dates, logging, and response). Endpoints now require authentication, validate dates, and log actions. CSRF handling remains a TODO (placeholder token in use). Test for proper date-setting and error handling. Added supporting methods `set_open_at` and `set_close_at` to the Election class in `election.py`, and corresponding cursors [...]
-## 2. Upcoming Elections Not Populated in `voter_page()`
+## 2. Upcoming Elections Not Populated in `voter_page()` - RESOLVED
- **Issue**: The `voter.ezt` template checks for `[if-any upcoming]` and loops over `upcoming` elections, but `voter_page()` only sets `result.election` (for open elections). `result.upcoming` is never defined, so the "Upcoming Elections" section will always be empty.
- **Impact**: Upcoming elections (e.g., those in 'editable' state with a future open date) won't display, confusing users.
-- **Suggested Fix**: Modify `voter_page()` to separate elections into `upcoming` and `election` (open ones). Assuming `steve.election.Election.open_to_pid()` returns all relevant elections, filter them:
- - `upcoming`: Elections where `state == 'editable'` and `open_at` is in the future (within `SOON_CUTOFF`).
- - `election`: The rest (open or closed, but template seems to handle closed via `(closed)` text).
- - Add: `result.upcoming = [postprocess_election(e) for e in election if e.state == steve.election.Election.S_EDITABLE and (e.open_at and e.open_at > datetime.datetime.now().timestamp())]`
- - Then, `result.election = [postprocess_election(e) for e in election if e not in result.upcoming]`
- - Update `result.len_election` accordingly.
+- **Resolution**: Added a new Election class method `upcoming_to_pid` to return editable elections for a given PID with voting eligibility. Added corresponding query `q_upcoming_to_me` in `queries.yaml`. Updated `voter_page()` to fetch and post-process upcoming elections into `result.upcoming`. Updated `voter.ezt` to include a dedicated "Upcoming Elections" section with similar card layout, a "Preview Ballot" link, and subtle visual distinction (lighter background, "Upcoming" badge). No [...]
## 3. Hardcoded `vtype` in `do_add_issue_endpoint()`
- **Issue**: `vtype` is hardcoded to `'yna'`, and `kv = None`. The comment mentions handling SEATS for STV, but it's not implemented. If users try to add STV issues, it will fail or behave incorrectly.
diff --git a/v3/server/pages.py b/v3/server/pages.py
index 8c9daf9..945fb95 100644
--- a/v3/server/pages.py
+++ b/v3/server/pages.py
@@ -11,7 +11,7 @@
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
+# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
@@ -154,6 +154,7 @@ async def voter_page():
owned = steve.election.Election.owned_elections(DB_FNAME, result.uid)
result.election = [postprocess_election(e) for e in election]
+ result.upcoming = [postprocess_election(e) for e in steve.election.Election.upcoming_to_pid(DB_FNAME, result.uid)]
result.len_election = len(election)
result.len_owned = len(owned)
diff --git a/v3/server/templates/voter.ezt b/v3/server/templates/voter.ezt
index 8def7c2..d4a6dc5 100644
--- a/v3/server/templates/voter.ezt
+++ b/v3/server/templates/voter.ezt
@@ -57,6 +57,52 @@
</div>
[end]
+ <h2>Upcoming Elections</h2>
+ [if-any upcoming]
+ [for upcoming]
+ <div class="w-auto mb-4">
+ <a href="/vote-on/[upcoming.eid]" class="text-decoration-none">
+ <div class="card h-100 bg-light">
+ <div class="card-body">
+ <h5 class="card-title">[upcoming.title] <span class="badge badge-secondary">Upcoming</span></h5>
+ <p class="card-text">
+ You have [upcoming.issue_count] issues to vote upon.
+ <br/>
+ eid: [upcoming.eid]
+
+ [if-any upcoming.open_at]
+ <div>
+ Opening
+ <span title="[upcoming.fmt_open_at_full]"
+ style="border-bottom: 1px dotted #007bff;"
+ >[upcoming.fmt_open_at]</span>
+ </div>
+ [end]
+ [if-any upcoming.close_at]
+ <div>
+ Closing
+ <span title="[upcoming.fmt_close_at_full]"
+ style="border-bottom: 1px dotted #007bff;"
+ >[upcoming.fmt_close_at]</span>
+ </div>
+ [end]
+
+ </p>
+ </div>
+ <div class="card-footer text-muted small">
+ Created by [upcoming.owner_name] ([upcoming.owner_pid])
+ [if-any upcoming.authz]
+ (authz: [upcoming.authz])
+ [end]
+ </div>
+ </div>
+ </a>
+ </div>
+ [end]
+ [else]
+ <p>No upcoming elections.</p>
+ [end]
+
<p>
You have [len_owned] <a href="/admin">elections to manage</a>.
</p>
(steve) 03/03: fix: correct undefined name 'iid' in IssueNotFound.__str__
Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit 92843a9b67f8a373debc84554e6c73f986134994
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 20 02:05:14 2026 -0600
fix: correct undefined name 'iid' in IssueNotFound.__str__
Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
v3/steve/election.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/v3/steve/election.py b/v3/steve/election.py
index 8d74d3f..a2c4230 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -230,7 +230,7 @@ class Election:
return iid
def edit_issue(self, iid, title, description, vtype, kv):
- "Update an existing issue designated by IID."
+ "Edit an existing issue designated by IID."
assert self.is_editable()
assert vtype in vtypes.TYPES
@@ -539,4 +539,4 @@ class IssueNotFound(Exception):
super().__init__(str(self))
def __str__(self):
- return f'Issue[I:{iid}] not found'
+ return f'Issue[I:{self.iid}] not found'