mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Merge branch 'master' into fix-new-jobs-showing-as-deleted
This commit is contained in:
@@ -55,7 +55,7 @@ class ModelList(ABC, Sequence):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def client(self):
|
||||
def client_method(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@@ -64,7 +64,7 @@ class ModelList(ABC, Sequence):
|
||||
pass
|
||||
|
||||
def __init__(self, *args):
|
||||
self.items = self.client(*args)
|
||||
self.items = self.client_method(*args)
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self.model(self.items[index])
|
||||
|
||||
@@ -157,12 +157,12 @@ class APIKeyEvent(Event):
|
||||
class APIKeyEvents(ModelList):
|
||||
|
||||
model = APIKeyEvent
|
||||
client = service_api_client.get_service_api_key_history
|
||||
client_method = service_api_client.get_service_api_key_history
|
||||
|
||||
|
||||
class ServiceEvents(ModelList):
|
||||
|
||||
client = service_api_client.get_service_service_history
|
||||
client_method = service_api_client.get_service_service_history
|
||||
|
||||
@property
|
||||
def model(self):
|
||||
@@ -187,5 +187,5 @@ class ServiceEvents(ModelList):
|
||||
|
||||
def __init__(self, service_id):
|
||||
self.items = [
|
||||
event for event in self.splat(self.client(service_id)) if event.relevant
|
||||
event for event in self.splat(self.client_method(service_id)) if event.relevant
|
||||
]
|
||||
|
||||
@@ -29,7 +29,6 @@ class Job(JSONModel):
|
||||
'created_at',
|
||||
'processing_started',
|
||||
'notification_count',
|
||||
'job_status',
|
||||
'created_by',
|
||||
}
|
||||
|
||||
@@ -39,7 +38,7 @@ class Job(JSONModel):
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
return self.job_status
|
||||
return self._dict.get('job_status')
|
||||
|
||||
@property
|
||||
def cancelled(self):
|
||||
@@ -205,28 +204,28 @@ class Job(JSONModel):
|
||||
|
||||
|
||||
class ImmediateJobs(ModelList):
|
||||
client = job_api_client.get_immediate_jobs
|
||||
client_method = job_api_client.get_immediate_jobs
|
||||
model = Job
|
||||
|
||||
|
||||
class ScheduledJobs(ImmediateJobs):
|
||||
client = job_api_client.get_scheduled_jobs
|
||||
client_method = job_api_client.get_scheduled_jobs
|
||||
|
||||
|
||||
class PaginatedJobs(ImmediateJobs):
|
||||
|
||||
client = job_api_client.get_page_of_jobs
|
||||
client_method = job_api_client.get_page_of_jobs
|
||||
|
||||
def __init__(self, service_id, page=None):
|
||||
try:
|
||||
self.current_page = int(page)
|
||||
except TypeError:
|
||||
self.current_page = 1
|
||||
response = self.client(service_id, page=self.current_page)
|
||||
response = self.client_method(service_id, page=self.current_page)
|
||||
self.items = response['data']
|
||||
self.prev_page = response.get('links', {}).get('prev', None)
|
||||
self.next_page = response.get('links', {}).get('next', None)
|
||||
|
||||
|
||||
class PaginatedUploads(PaginatedJobs):
|
||||
client = job_api_client.get_uploads
|
||||
client_method = job_api_client.get_uploads
|
||||
|
||||
@@ -200,5 +200,5 @@ class Organisation(JSONModel):
|
||||
|
||||
|
||||
class Organisations(ModelList):
|
||||
client = organisations_client.get_organisations
|
||||
client_method = organisations_client.get_organisations
|
||||
model = Organisation
|
||||
|
||||
@@ -614,12 +614,9 @@ class AnonymousUser(AnonymousUserMixin):
|
||||
|
||||
class Users(ModelList):
|
||||
|
||||
client = user_api_client.get_users_for_service
|
||||
client_method = user_api_client.get_users_for_service
|
||||
model = User
|
||||
|
||||
def __init__(self, service_id):
|
||||
self.items = self.client(service_id)
|
||||
|
||||
def get_name_from_id(self, id):
|
||||
for user in self:
|
||||
if user.id == id:
|
||||
@@ -628,21 +625,21 @@ class Users(ModelList):
|
||||
|
||||
|
||||
class OrganisationUsers(Users):
|
||||
client = user_api_client.get_users_for_organisation
|
||||
client_method = user_api_client.get_users_for_organisation
|
||||
|
||||
|
||||
class InvitedUsers(Users):
|
||||
|
||||
client = invite_api_client.get_invites_for_service
|
||||
client_method = invite_api_client.get_invites_for_service
|
||||
model = InvitedUser
|
||||
|
||||
def __init__(self, service_id):
|
||||
self.items = [
|
||||
user for user in self.client(service_id)
|
||||
user for user in self.client_method(service_id)
|
||||
if user['status'] != 'accepted'
|
||||
]
|
||||
|
||||
|
||||
class OrganisationInvitedUsers(InvitedUsers):
|
||||
client = org_invite_api_client.get_invites_for_organisation
|
||||
client_method = org_invite_api_client.get_invites_for_organisation
|
||||
model = InvitedOrgUser
|
||||
|
||||
Reference in New Issue
Block a user