Refactor to make it logic clearer

The logic around what gets shown on the uploads page was hard to follow.
This commit makes three changes to hopefully make it easier:
- remove the passing-around of a string containing the contents of a
  rendered partial
- encapsulate everything in one `show_scheduled_jobs` variable, rather
  than mixing between `scheduled_jobs` and
  `current_service.scheduled_jobs`
- adds a comment to explain why we still render `_jobs.html` even when
  we know we have no jobs
This commit is contained in:
Chris Hill-Scott
2020-02-24 10:59:57 +00:00
parent c20ec82cd2
commit 3dab9c2915
3 changed files with 21 additions and 18 deletions

View File

@@ -52,19 +52,14 @@ def uploads(service_id):
if uploads.prev_page:
next_page = generate_next_dict('main.uploads', service_id, uploads.current_page)
scheduled_jobs = ''
if uploads.current_page == 1:
scheduled_jobs = render_template(
'views/dashboard/_upcoming.html',
hide_heading=True,
)
return render_template(
'views/jobs/jobs.html',
jobs=uploads,
prev_page=prev_page,
next_page=next_page,
scheduled_jobs=scheduled_jobs,
show_scheduled_jobs=(
uploads.current_page == 1 and current_service.scheduled_jobs
),
)