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