From 2b6588a0acdcd7d730d83e1fcbe536416f0e563c Mon Sep 17 00:00:00 2001 From: Karim El Jazzar Date: Wed, 11 Mar 2026 13:05:41 -0700 Subject: [PATCH] feat(api): only show applications in applications table --- strr-api/pyproject.toml | 2 +- strr-api/src/strr_api/models/application.py | 14 +++++++------- strr-api/src/strr_api/resources/application.py | 2 +- .../unit/resources/test_renewal_applications.py | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/strr-api/pyproject.toml b/strr-api/pyproject.toml index b9c0a0334..50464a8bf 100644 --- a/strr-api/pyproject.toml +++ b/strr-api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "strr-api" -version = "0.3.10" +version = "0.3.11" description = "" authors = ["thorwolpert "] license = "BSD 3-Clause" diff --git a/strr-api/src/strr_api/models/application.py b/strr-api/src/strr_api/models/application.py index 82966eef7..6538ed28a 100644 --- a/strr-api/src/strr_api/models/application.py +++ b/strr-api/src/strr_api/models/application.py @@ -224,14 +224,14 @@ def find_by_account( ) ) if filter_criteria.applications_only: - # Exclude applications that have a completed registration, except renewals - # Include: no registration yet or renewal applications - query = query.filter( - db.or_( - Application.registration_id.is_(None), - Application.type == ApplicationType.RENEWAL.value, - ) + # Exclude all applications that have an associated registration. + query = query.filter(Application.registration_id.is_(None)) + # Also exclude when application_json has a registrationId in header (any non-null, non-empty value) + no_reg_in_json = db.or_( + Application.application_json["header"]["registrationId"].astext.is_(None), + Application.application_json["header"]["registrationId"].astext == "", ) + query = query.filter(no_reg_in_json) sort_column = getattr(Application, filter_criteria.sort_by, Application.id) if filter_criteria.sort_order and filter_criteria.sort_order.lower() == "asc": query = query.order_by(sort_column.asc()) diff --git a/strr-api/src/strr_api/resources/application.py b/strr-api/src/strr_api/resources/application.py index a3627f4be..5da7b31bf 100644 --- a/strr-api/src/strr_api/resources/application.py +++ b/strr-api/src/strr_api/resources/application.py @@ -268,7 +268,7 @@ def get_applications(): name: applicationsOnly type: boolean default: false - description: When true, exclude applications that have a completed registration (except renewals). For split dashboard applications table. + description: When true, exclude all applications that have an associated registration (including renewals). For split dashboard applications table. responses: 200: description: diff --git a/strr-api/tests/unit/resources/test_renewal_applications.py b/strr-api/tests/unit/resources/test_renewal_applications.py index c6f28b59d..6e6551cf9 100644 --- a/strr-api/tests/unit/resources/test_renewal_applications.py +++ b/strr-api/tests/unit/resources/test_renewal_applications.py @@ -91,15 +91,14 @@ def test_host_renewal_application_submission(session, client, jwt, request_json, assert application.registration_id == registration_id assert application.type == "renewal" - # Test applicationsOnly includes renewal applications (renewals have registration_id but are shown) + # Test applicationsOnly excludes renewal applications (renewals have registration_id and are hidden) rv = client.get( f"/applications?recordNumber={renewal_application_number}&applicationsOnly=true", headers=staff_headers, ) response_json = rv.json assert rv.status_code == 200 - assert len(response_json.get("applications")) == 1 - assert response_json.get("applications")[0]["header"]["applicationNumber"] == renewal_application_number + assert len(response_json.get("applications")) == 0 @pytest.mark.parametrize(