mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-12 18:08:57 -04:00
Combine scheduled and already-sent jobs
I’m hoping that if I can design something that clearly differentiates them then we won’t need to do so by putting them in separate tables, which then need labelling, which would clutter up the page.
This commit is contained in:
@@ -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
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user