mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
give test letter api notifications a different filename
so they can be distinguished on the frontend. Also, some related cleanup: * don't show test api letters on the frontpage * make sure the subject is returned from the API for letters * make sure the letter's address is returned for letters
This commit is contained in:
@@ -11,6 +11,7 @@ from app.models import (
|
||||
JOB_STATUS_SCHEDULED, JOB_STATUS_PENDING,
|
||||
LETTER_TYPE
|
||||
)
|
||||
from app.variables import LETTER_TEST_API_FILENAME
|
||||
from app.statsd_decorators import statsd
|
||||
|
||||
|
||||
@@ -142,9 +143,18 @@ def dao_get_jobs_older_than_limited_by(job_types, older_than=7, limit_days=2):
|
||||
|
||||
|
||||
def dao_get_all_letter_jobs():
|
||||
return db.session.query(Job).join(Job.template).filter(
|
||||
Template.template_type == LETTER_TYPE
|
||||
).order_by(desc(Job.created_at)).all()
|
||||
return db.session.query(
|
||||
Job
|
||||
).join(
|
||||
Job.template
|
||||
).filter(
|
||||
Template.template_type == LETTER_TYPE,
|
||||
# test letter jobs (or from research mode services) are created with a different filename,
|
||||
# exclude them so we don't see them on the send to CSV
|
||||
Job.original_file_name != LETTER_TEST_API_FILENAME
|
||||
).order_by(
|
||||
desc(Job.created_at)
|
||||
).all()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
|
||||
@@ -338,7 +338,8 @@ def get_notifications_for_service(
|
||||
filters.append(Notification.created_at < older_than_created_at)
|
||||
|
||||
if not include_jobs or (key_type and key_type != KEY_TYPE_NORMAL):
|
||||
filters.append(Notification.job_id.is_(None))
|
||||
# we can't say "job_id == None" here, because letters sent via the API still have a job_id :(
|
||||
filters.append(Notification.api_key_id != None) # noqa
|
||||
|
||||
if key_type is not None:
|
||||
filters.append(Notification.key_type == key_type)
|
||||
|
||||
Reference in New Issue
Block a user