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 047858d4da29db67c31416b2b39c320d83d0d8dc
Author: Greg Stein <[email protected]>
AuthorDate: Tue Oct 7 07:43:25 2025 -0500

    Populate "owner_name" in the template data.
---
 v3/queries.yaml    |  4 +++-
 v3/server/pages.py | 22 ++++++++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/v3/queries.yaml b/v3/queries.yaml
index be93e24..750a7f7 100644
--- a/v3/queries.yaml
+++ b/v3/queries.yaml
@@ -93,10 +93,12 @@ election:
         SELECT e.eid, e.title, e.owner_pid, e.authz, e.closed,
                e.open_at, e.close_at,
                (e.opened_key IS NOT NULL) AS is_opened,
-               COUNT(i.iid) AS issue_count
+               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
+        INNER JOIN person p ON e.owner_pid = p.pid
         WHERE m.pid = ?
           AND e.salt IS NOT NULL
           AND (e.closed IS NULL OR e.closed = 0)
diff --git a/v3/server/pages.py b/v3/server/pages.py
index 9bfadfb..daaedd6 100644
--- a/v3/server/pages.py
+++ b/v3/server/pages.py
@@ -45,6 +45,7 @@ TEMPLATES = THIS_DIR / 'templates'
 sys.path.insert(0, str(THIS_DIR.parent))
 import steve.election
 import steve.crypto
+import steve.persondb
 
 # Formatted values to inject into templates.
 FMT_DATE = '%b %d'
@@ -154,6 +155,25 @@ async def admin_page():
 
     result.owned = [ postprocess_election(e) for e in owned ]
 
+    ### owned.owner_name should be based on OWNER_PID. That might not be
+    ### "me" because of authz access to manage issues.
+
+    ### should open/keep a PersonDB instance in the APP
+    pdb = steve.persondb.PersonDB(DB_FNAME)
+    try:
+        me = pdb.get_person(result.uid)
+    except AttributeError:
+        ### the committer is not in "person"
+        ### this is a terrible way to signal this. return None?
+        ### what kind of error/page to raise?
+        raise
+
+    ### the query for OWNED is just for "me", so this is the correct
+    ### name at the moment. When authz kicks in ... Nope.
+    # me is (name, email)
+    for e in result.owned:
+        e.owner_name = me[0]
+
     result.len_election = len(election)
     result.len_owned = len(owned)
 
@@ -261,8 +281,6 @@ def postprocess_election(e):
         e.owner_pid = 'gstein'  ### fix query. for now, could be result.uid
     if 'issue_count' not in e:
         e.issue_count = 5  ### arbitrary. just provide a value
-    if 'owner_name' not in e:
-        e.owner_name = 'Jane Doe'
 
     return e
 

Reply via email to