mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Refactor ‘finished’ to the model layer
By moving it from the view we reduce the complexity of the methods in the view layer, so it’s easier to see what they do. This also renames the variable `finished` to the property `processing_finished` to disambiguate from the `job_status` field in the JSON, which can also have a value of `finished`.
This commit is contained in:
@@ -77,9 +77,6 @@ def view_job(service_id, job_id):
|
|||||||
filter_args = parse_filter_args(request.args)
|
filter_args = parse_filter_args(request.args)
|
||||||
filter_args['status'] = set_status_filters(filter_args)
|
filter_args['status'] = set_status_filters(filter_args)
|
||||||
|
|
||||||
total_notifications = job.notification_count
|
|
||||||
processed_notifications = job.notifications_processed
|
|
||||||
|
|
||||||
just_sent_message = 'Your {} been sent. Printing starts {} at 5:30pm.'.format(
|
just_sent_message = 'Your {} been sent. Printing starts {} at 5:30pm.'.format(
|
||||||
'letter has' if job.notification_count == 1 else 'letters have',
|
'letter has' if job.notification_count == 1 else 'letters have',
|
||||||
printing_today_or_tomorrow()
|
printing_today_or_tomorrow()
|
||||||
@@ -87,7 +84,6 @@ def view_job(service_id, job_id):
|
|||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/jobs/job.html',
|
'views/jobs/job.html',
|
||||||
finished=(total_notifications == processed_notifications),
|
|
||||||
job=job,
|
job=job,
|
||||||
status=request.args.get('status', ''),
|
status=request.args.get('status', ''),
|
||||||
updates_url=url_for(
|
updates_url=url_for(
|
||||||
|
|||||||
@@ -83,10 +83,13 @@ class Job(JSONModel):
|
|||||||
@property
|
@property
|
||||||
def still_processing(self):
|
def still_processing(self):
|
||||||
return (
|
return (
|
||||||
self.status != 'finished' or
|
self.status != 'finished' or self.percentage_complete < 100
|
||||||
self.notifications_created < self.notification_count
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def finished_processing(self):
|
||||||
|
return self.notification_count == self.notifications_processed
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def template_id(self):
|
def template_id(self):
|
||||||
return self._dict['template']
|
return self._dict['template']
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
{% if template.template_type == 'letter' %}
|
{% if template.template_type == 'letter' %}
|
||||||
<div class="keyline-block bottom-gutter-1-2">
|
<div class="keyline-block bottom-gutter-1-2">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if job.percentage_complete < 100 and job.job_status != 'finished' %}
|
{% if job.still_processing %}
|
||||||
<p class="{% if job.template.template_type != 'letter' %}bottom-gutter{% endif %} hint">
|
<p class="{% if job.template.template_type != 'letter' %}bottom-gutter{% endif %} hint">
|
||||||
Report is {{ "{:.0f}%".format(job.percentage_complete * 0.99) }} complete…
|
Report is {{ "{:.0f}%".format(job.percentage_complete * 0.99) }} complete…
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
{% if just_sent %}
|
{% if just_sent %}
|
||||||
{{ banner(just_sent_message, type='default', with_tick=True) }}
|
{{ banner(just_sent_message, type='default', with_tick=True) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ ajax_block(partials, updates_url, 'status', finished=finished) }}
|
{{ ajax_block(partials, updates_url, 'status', finished=job.processing_finished) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ ajax_block(partials, updates_url, 'counts', finished=finished) }}
|
{{ ajax_block(partials, updates_url, 'counts', finished=job.processing_finished) }}
|
||||||
{{ ajax_block(partials, updates_url, 'notifications', finished=finished) }}
|
{{ ajax_block(partials, updates_url, 'notifications', finished=job.processing_finished) }}
|
||||||
|
|
||||||
{% if job.letter_job_can_be_cancelled %}
|
{% if job.letter_job_can_be_cancelled %}
|
||||||
<div class="js-stick-at-bottom-when-scrolling">
|
<div class="js-stick-at-bottom-when-scrolling">
|
||||||
|
|||||||
Reference in New Issue
Block a user