mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Add method to get jobs for a contact list
Because the API lets us query jobs by contact list now, let’s add the model and client layer code that will let us display them in the admin app.
This commit is contained in:
@@ -8,6 +8,7 @@ from notifications_utils.timezones import utc_string_to_aware_gmt_datetime
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
from app.models import JSONModel, ModelList
|
||||
from app.models.job import PaginatedJobs
|
||||
from app.notify_client.contact_list_api_client import contact_list_api_client
|
||||
from app.s3_client.s3_csv_client import (
|
||||
get_csv_metadata,
|
||||
@@ -134,6 +135,13 @@ class ContactList(JSONModel):
|
||||
file_name, extention = path.splitext(self.original_file_name)
|
||||
return f'{file_name}.csv'
|
||||
|
||||
def get_jobs(self, *, page):
|
||||
return PaginatedJobs(
|
||||
self.service_id,
|
||||
contact_list_id=self.id,
|
||||
page=page,
|
||||
)
|
||||
|
||||
|
||||
class ContactLists(ModelList):
|
||||
|
||||
|
||||
@@ -234,8 +234,8 @@ class ScheduledJobs(ImmediateJobs):
|
||||
class PaginatedJobs(PaginatedModelList, ImmediateJobs):
|
||||
client_method = job_api_client.get_page_of_jobs
|
||||
|
||||
def __init__(self, service_id, *, page=None):
|
||||
super().__init__(service_id, page=page)
|
||||
def __init__(self, service_id, *, contact_list_id=None, page=None):
|
||||
super().__init__(service_id, contact_list_id=contact_list_id, page=page)
|
||||
|
||||
|
||||
class PaginatedUploads(PaginatedModelList, ImmediateJobs):
|
||||
|
||||
Reference in New Issue
Block a user