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 4ba86c227a65a2af4ee4f1c3c0ef1002132a007e Author: Greg Stein <[email protected]> AuthorDate: Thu Oct 2 04:42:57 2025 -0500 Display Election open/close status, and date phrasing. --- v3/queries.yaml | 6 ++++-- v3/server/pages.py | 11 +++++++++-- v3/server/templates/voter.ezt | 17 ++++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/v3/queries.yaml b/v3/queries.yaml index 6572b37..c7dec8b 100644 --- a/v3/queries.yaml +++ b/v3/queries.yaml @@ -89,7 +89,8 @@ election: # Note: SALT and OPENED_KEY are never returned. q_open_to_me: | SELECT DISTINCT e.eid, e.title, e.owner_pid, e.authz, e.closed, - e.open_at, e.close_at + e.open_at, e.close_at, + (e.opened_key IS NOT NULL) AS is_opened FROM mayvote m JOIN issue i ON m.iid = i.iid JOIN election e ON i.eid = e.eid @@ -100,7 +101,8 @@ election: # Which elections were created by PID? q_owned: | - SELECT eid, title, authz, closed, open_at, close_at + SELECT eid, title, authz, closed, open_at, close_at, + (opened_key IS NOT NULL) AS is_opened FROM election WHERE owner_pid = ? diff --git a/v3/server/pages.py b/v3/server/pages.py index d5555e7..d6f2ca4 100644 --- a/v3/server/pages.py +++ b/v3/server/pages.py @@ -96,12 +96,14 @@ async def voter_page(): ).timestamp() def new_test_election(): + import random return edict( eid=steve.crypto.create_id(), title=f'Title blah:{steve.crypto.create_id()}', owner_pid='alice', authz=None, - closed=None, + is_opened=(random.randrange(10) < 3), # open 30% + closed=(random.randrange(10) < 3), # closed 30% open_at=some_future(), close_at=some_future(), ) @@ -194,9 +196,14 @@ def format_datetime(dt): def postprocess_election(e): "Post-process attributes in an Election, as an EasyDict." - # Anything but 1 means the Election is Open. + # Anything but 1 means the Election is not closed. e.closed = ezt.boolean(e.closed == 1) + # Anything but 1 means the Election is not open. + e.is_opened = ezt.boolean(e.is_opened == 1) + + # note: an election has an Edit state: not open, not closed. + # Format dates, if present. dt_open = e.open_at and datetime.datetime.fromtimestamp(e.open_at) e.fmt_open_at = format_datetime(dt_open) diff --git a/v3/server/templates/voter.ezt b/v3/server/templates/voter.ezt index 1699a71..e70cd4c 100644 --- a/v3/server/templates/voter.ezt +++ b/v3/server/templates/voter.ezt @@ -7,7 +7,9 @@ <a href="#" class="text-decoration-none"> <div class="card h-100"> <div class="card-body"> - <h5 class="card-title">[election.title]</h5> + <h5 class="card-title">[election.title][# + ][if-any election.is_opened] (open)[else][# + ][if-any election.closed] (closed)[end][end]</h5> <p class="card-text"> something about the election? <br/> @@ -25,20 +27,25 @@ Closed on <span title="[election.fmt_close_at_full]">[election.fmt_close_at]</span> [else] - already open? [if-any election.open_at] - <br/> - Opening + <div> + [if-any election.is_opened] + Opened + [else] + Opening + [end] <span title="[election.fmt_open_at_full]" style="border-bottom: 1px dotted #007bff;" >[election.fmt_open_at]</span> + </div> [end] [if-any election.close_at] - <br/> + <div> Closing <span title="[election.fmt_close_at_full]" style="border-bottom: 1px dotted #007bff;" >[election.fmt_close_at]</span> + </div> [end] [end] </div>
