mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 17:28:24 -04:00
Sort services and orgs in presentation layer
The model layer shouldn’t need to be concerned with sorting. For services this means we can make a `SerialisedModelCollection` rather than writing a manual loop.
This commit is contained in:
@@ -293,9 +293,9 @@ class User(JSONModel, UserMixin):
|
|||||||
@property
|
@property
|
||||||
def services(self):
|
def services(self):
|
||||||
from app.models.service import Service
|
from app.models.service import Service
|
||||||
return sorted(
|
return [
|
||||||
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):
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<ul>
|
<ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for org in organisations %}
|
{% for org in organisations|sort %}
|
||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="govuk-link govuk-link--no-visited-state">{{ org.name }}</a>
|
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="govuk-link govuk-link--no-visited-state">{{ org.name }}</a>
|
||||||
<p class="browse-list-hint">
|
<p class="browse-list-hint">
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for service in services %}
|
{% for service in services|sort %}
|
||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<a href="{{ url_for('.service_dashboard', service_id=service.id) }}" class="govuk-link govuk-link--no-visited-state">{{ service.name }}</a>
|
<a href="{{ url_for('.service_dashboard', service_id=service.id) }}" class="govuk-link govuk-link--no-visited-state">{{ service.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user