mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-27 04:31:11 -04:00
Make a model collection for services
This is tidier than having a manual loop.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from flask import abort, current_app
|
||||
from notifications_utils.serialised_model import SerialisedModelCollection
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
from app.models import JSONModel
|
||||
@@ -710,3 +711,7 @@ class Service(JSONModel):
|
||||
@property
|
||||
def contact_lists(self):
|
||||
return ContactLists(self.id)
|
||||
|
||||
|
||||
class Services(SerialisedModelCollection):
|
||||
model = Service
|
||||
|
||||
@@ -292,10 +292,8 @@ class User(JSONModel, UserMixin):
|
||||
|
||||
@property
|
||||
def services(self):
|
||||
from app.models.service import Service
|
||||
return [
|
||||
Service(service) for service in self.orgs_and_services['services']
|
||||
]
|
||||
from app.models.service import Services
|
||||
return Services(self.orgs_and_services['services'])
|
||||
|
||||
@property
|
||||
def services_with_organisation(self):
|
||||
|
||||
Reference in New Issue
Block a user