diff --git a/app/main/views/uploads.py b/app/main/views/uploads.py index 65edfcfc2..961b1ae80 100644 --- a/app/main/views/uploads.py +++ b/app/main/views/uploads.py @@ -52,14 +52,16 @@ def uploads(service_id): if uploads.prev_page: next_page = generate_next_dict('main.uploads', service_id, uploads.current_page) + if uploads.current_page == 1: + listed_uploads = current_service.scheduled_jobs + uploads + else: + listed_uploads = uploads + return render_template( 'views/jobs/jobs.html', - jobs=uploads, + jobs=listed_uploads, prev_page=prev_page, next_page=next_page, - show_scheduled_jobs=( - uploads.current_page == 1 and current_service.scheduled_jobs - ), ) diff --git a/app/models/__init__.py b/app/models/__init__.py index 4f8850e9d..6034f4fb3 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -76,5 +76,13 @@ class ModelList(ABC, Sequence): return list(self) + list(other) +class EmptyModelList(ModelList): + + client_method = model = None + + def __init__(self, *args): + self.items = [] + + class InviteTokenError(Exception): pass diff --git a/app/models/service.py b/app/models/service.py index 132ac157c..0ee6217b0 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -5,7 +5,7 @@ from flask import abort, current_app from notifications_utils.timezones import local_timezone from werkzeug.utils import cached_property -from app.models import JSONModel +from app.models import EmptyModelList, JSONModel from app.models.job import ( ImmediateJobs, PaginatedJobs, @@ -123,13 +123,13 @@ class Service(JSONModel): @cached_property def immediate_jobs(self): if not self.has_jobs: - return [] + return EmptyModelList() return ImmediateJobs(self.id) @cached_property def scheduled_jobs(self): if not self.has_jobs: - return [] + return EmptyModelList() return ScheduledJobs(self.id) @cached_property diff --git a/tests/app/main/views/test_uploads.py b/tests/app/main/views/test_uploads.py index cbb7a5396..b36791533 100644 --- a/tests/app/main/views/test_uploads.py +++ b/tests/app/main/views/test_uploads.py @@ -643,15 +643,15 @@ def test_uploads_page_shows_scheduled_jobs( normalize_spaces(row.text) for row in page.select('tr') ] == [ ( - 'File Messages to be sent' + 'File Sending Delivered Failed' ), ( 'send_me_later.csv ' - 'Sending 1 January 2016 at 11:09am 1' + 'Sent 1 January 2016 at 11:09am 0 0 0' ), ( 'even_later.csv ' - 'Sending 1 January 2016 at 11:09pm 1' + 'Sent 1 January 2016 at 11:09pm 0 0 0' ), ] assert not page.select('.table-empty-message')