Make a function for parsing help query param

Our templates are a littered with `request.args.get('help', '0')`.
This commit refactors these into a single helper method, which can be
used by the view functions, then passed to the template.

This makes the templates cleaner, and should make it easier to refactor
`help` out of the query parameters entirely in the future.
This commit is contained in:
Chris Hill-Scott
2016-07-05 17:29:41 +01:00
parent d71269ca87
commit 80e0832f7d
7 changed files with 22 additions and 13 deletions
+5 -2
View File
@@ -28,6 +28,7 @@ from app.utils import (
user_has_permissions,
generate_notifications_csv)
from app.statistics_utils import sum_of_statistics, statistics_by_state, add_rate_to_jobs
from app.utils import get_help_argument
def _parse_filter_args(filter_dict):
@@ -98,7 +99,8 @@ def view_job(service_id, job_id):
job_id=job['id'],
status=request.args.get('status', '')
),
partials=get_job_partials(job)
partials=get_job_partials(job),
help=get_help_argument()
)
@@ -311,7 +313,8 @@ def get_job_partials(job):
notifications=notification_api_client.get_notifications_for_service(
job['service'], job['id'], status=filter_args.get('status')
)['notifications'],
status=request.args.get('status', '')
status=request.args.get('status', ''),
help=get_help_argument()
),
'status': render_template(
'partials/jobs/status.html',