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:
Chris Hill-Scott
2020-02-27 10:49:23 +00:00
parent 0d4c97e64a
commit eed5e0fdd7
4 changed files with 20 additions and 10 deletions

View File

@@ -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
),
)

View File

@@ -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

View File

@@ -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