mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:09:49 -04:00
Make services natively sortable
This commit is contained in:
@@ -59,6 +59,9 @@ class Organisation(JSONModel):
|
|||||||
return cls({})
|
return cls({})
|
||||||
return cls(organisations_client.get_organisation(org_id))
|
return cls(organisations_client.get_organisation(org_id))
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
return self.name.lower() < other.name.lower()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_domain(cls, domain):
|
def from_domain(cls, domain):
|
||||||
return cls(organisations_client.get_organisation_by_domain(domain))
|
return cls(organisations_client.get_organisation_by_domain(domain))
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ class Service(JSONModel):
|
|||||||
def from_id(cls, service_id):
|
def from_id(cls, service_id):
|
||||||
return cls(service_api_client.get_service(service_id)['data'])
|
return cls(service_api_client.get_service(service_id)['data'])
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
return self.name.lower() < other.name.lower()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def permissions(self):
|
def permissions(self):
|
||||||
return self._dict.get('permissions', self.TEMPLATE_TYPES)
|
return self._dict.get('permissions', self.TEMPLATE_TYPES)
|
||||||
|
|||||||
@@ -290,16 +290,12 @@ class User(JSONModel, UserMixin):
|
|||||||
def orgs_and_services(self):
|
def orgs_and_services(self):
|
||||||
return user_api_client.get_organisations_and_services_for_user(self.id)
|
return user_api_client.get_organisations_and_services_for_user(self.id)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def sort_services(services):
|
|
||||||
return sorted(services, key=lambda service: service.name.lower())
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def services(self):
|
def services(self):
|
||||||
from app.models.service import Service
|
from app.models.service import Service
|
||||||
return self.sort_services([
|
return sorted(
|
||||||
Service(service) for service in self.orgs_and_services['services']
|
Service(service) for service in self.orgs_and_services['services']
|
||||||
])
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def services_with_organisation(self):
|
def services_with_organisation(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user