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 2025/10/13 07:47:03 UTC
(steve) 02/02: Improve handling for a Person not found.
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 68fafd36572300c067f0241e19087f91869e98c7
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Mon Oct 13 02:45:02 2025 -0500
Improve handling for a Person not found.
* add templates for person and issue not found.
* note in e_bad_eid that we won't show flashes
(same for other error pages; flashes should not happen)
* capture persondb.PersonNotFound, and show error page
note: E_BAD_IID is not yet used. Placeholder.
---
v3/server/pages.py | 19 +++++++++++++------
v3/server/templates/e_bad_eid.ezt | 2 ++
v3/server/templates/{e_bad_eid.ezt => e_bad_iid.ezt} | 7 ++++---
v3/server/templates/{e_bad_eid.ezt => e_bad_pid.ezt} | 7 ++++---
4 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/v3/server/pages.py b/v3/server/pages.py
index 378c0c9..8b5fcde 100644
--- a/v3/server/pages.py
+++ b/v3/server/pages.py
@@ -54,6 +54,8 @@ SOON_1HOUR = 60 * 60
SOON_CUTOFF = 48 * SOON_1HOUR # 48 hours, in seconds
T_BAD_EID = APP.load_template(TEMPLATES / 'e_bad_eid.ezt')
+T_BAD_IID = APP.load_template(TEMPLATES / 'e_bad_iid.ezt')
+T_BAD_PID = APP.load_template(TEMPLATES / 'e_bad_pid.ezt')
async def basic_info():
@@ -182,11 +184,15 @@ async def admin_page():
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
+ except steve.persondb.PersonNotFound:
+ ### the authn'd committer is not in "person"
+
+ result = await basic_info()
+ result.title = 'Unknown Person'
+ result.pid = pid
+ # Note: result.uid (and friends) are needed for the navbar.
+ raise_404(T_BAD_PID, result)
+ # NOTREACHED
### the query for OWNED is just for "me", so this is the correct
### name at the moment. When authz kicks in ... Nope.
@@ -387,7 +393,8 @@ def postprocess_election(e):
# 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.
+ # note: an election has a third Edit state: not open, not closed;
+ # this is called "editable" (S_EDITABLE)
# Format dates, if present.
dt_open = e.open_at and datetime.datetime.fromtimestamp(e.open_at)
diff --git a/v3/server/templates/e_bad_eid.ezt b/v3/server/templates/e_bad_eid.ezt
index 57cfd68..52ad63a 100644
--- a/v3/server/templates/e_bad_eid.ezt
+++ b/v3/server/templates/e_bad_eid.ezt
@@ -1,6 +1,8 @@
[include "header.ezt"]
<div class="container">
<h1>[title]</h1>
+ [# skipping flashes.ezt ]
+
<p>
[# we could be more specific. simpler to re-use. ]
diff --git a/v3/server/templates/e_bad_eid.ezt b/v3/server/templates/e_bad_iid.ezt
similarity index 62%
copy from v3/server/templates/e_bad_eid.ezt
copy to v3/server/templates/e_bad_iid.ezt
index 57cfd68..a1e3445 100644
--- a/v3/server/templates/e_bad_eid.ezt
+++ b/v3/server/templates/e_bad_iid.ezt
@@ -1,12 +1,13 @@
[include "header.ezt"]
<div class="container">
<h1>[title]</h1>
+ [# skipping flashes.ezt ]
+
<p>
[# we could be more specific. simpler to re-use. ]
- The Election ID ([eid]) does not exist,
- you have no issues to vote in that Election,
- or you are not allowed to manage that Election.
+ The Issue ID ([iid]) does not exist, or you do not
+ have access to vote or manage that issue.
</p>
<p>
<a href="/">Return to the home page</a>
diff --git a/v3/server/templates/e_bad_eid.ezt b/v3/server/templates/e_bad_pid.ezt
similarity index 62%
copy from v3/server/templates/e_bad_eid.ezt
copy to v3/server/templates/e_bad_pid.ezt
index 57cfd68..4259088 100644
--- a/v3/server/templates/e_bad_eid.ezt
+++ b/v3/server/templates/e_bad_pid.ezt
@@ -1,12 +1,13 @@
[include "header.ezt"]
<div class="container">
<h1>[title]</h1>
+ [# skipping flashes.ezt ]
+
<p>
[# we could be more specific. simpler to re-use. ]
- The Election ID ([eid]) does not exist,
- you have no issues to vote in that Election,
- or you are not allowed to manage that Election.
+ The Person ID ([pid]) does not exist, or you do not
+ have access to view information about that Person.
</p>
<p>
<a href="/">Return to the home page</a>