mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 04:23:11 -04:00
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:
@@ -51,19 +51,16 @@ def view_jobs(service_id):
|
|||||||
if jobs.next_page:
|
if jobs.next_page:
|
||||||
next_page = generate_next_dict('main.view_jobs', service_id, jobs.current_page)
|
next_page = generate_next_dict('main.view_jobs', service_id, jobs.current_page)
|
||||||
|
|
||||||
scheduled_jobs = ''
|
|
||||||
if not current_user.has_permissions('view_activity') and jobs.current_page == 1:
|
|
||||||
scheduled_jobs = render_template(
|
|
||||||
'views/dashboard/_upcoming.html',
|
|
||||||
hide_heading=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/jobs/jobs.html',
|
'views/jobs/jobs.html',
|
||||||
jobs=jobs,
|
jobs=jobs,
|
||||||
prev_page=prev_page,
|
prev_page=prev_page,
|
||||||
next_page=next_page,
|
next_page=next_page,
|
||||||
scheduled_jobs=scheduled_jobs,
|
show_scheduled_jobs=(
|
||||||
|
jobs.current_page == 1
|
||||||
|
and not current_user.has_permissions('view_activity')
|
||||||
|
and current_service.scheduled_jobs
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,19 +52,14 @@ def uploads(service_id):
|
|||||||
if uploads.prev_page:
|
if uploads.prev_page:
|
||||||
next_page = generate_next_dict('main.uploads', service_id, uploads.current_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(
|
return render_template(
|
||||||
'views/jobs/jobs.html',
|
'views/jobs/jobs.html',
|
||||||
jobs=uploads,
|
jobs=uploads,
|
||||||
prev_page=prev_page,
|
prev_page=prev_page,
|
||||||
next_page=next_page,
|
next_page=next_page,
|
||||||
scheduled_jobs=scheduled_jobs,
|
show_scheduled_jobs=(
|
||||||
|
uploads.current_page == 1 and current_service.scheduled_jobs
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,19 @@
|
|||||||
{% block maincolumn_content %}
|
{% block maincolumn_content %}
|
||||||
<h1 class="heading-large">Uploads</h1>
|
<h1 class="heading-large">Uploads</h1>
|
||||||
<div class="dashboard">
|
<div class="dashboard">
|
||||||
{{ scheduled_jobs|safe }}
|
{% if show_scheduled_jobs %}
|
||||||
{% if jobs or not current_service.scheduled_jobs %}
|
{% with hide_heading = True %}
|
||||||
|
{% include 'views/dashboard/_upcoming.html' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
|
{% if jobs %}
|
||||||
|
{% include 'views/dashboard/_jobs.html' %}
|
||||||
|
{% endif %}
|
||||||
|
{% if not jobs and not show_scheduled_jobs %}
|
||||||
|
{#
|
||||||
|
`_jobs.html` will show the ‘You have no jobs’ message when
|
||||||
|
passed an empty list of jobs
|
||||||
|
#}
|
||||||
{% include 'views/dashboard/_jobs.html' %}
|
{% include 'views/dashboard/_jobs.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ previous_next_navigation(prev_page, next_page) }}
|
{{ previous_next_navigation(prev_page, next_page) }}
|
||||||
|
|||||||
Reference in New Issue
Block a user