mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -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 flask import abort, current_app
|
||||||
|
from notifications_utils.serialised_model import SerialisedModelCollection
|
||||||
from werkzeug.utils import cached_property
|
from werkzeug.utils import cached_property
|
||||||
|
|
||||||
from app.models import JSONModel
|
from app.models import JSONModel
|
||||||
@@ -710,3 +711,7 @@ class Service(JSONModel):
|
|||||||
@property
|
@property
|
||||||
def contact_lists(self):
|
def contact_lists(self):
|
||||||
return ContactLists(self.id)
|
return ContactLists(self.id)
|
||||||
|
|
||||||
|
|
||||||
|
class Services(SerialisedModelCollection):
|
||||||
|
model = Service
|
||||||
|
|||||||
@@ -292,10 +292,8 @@ class User(JSONModel, UserMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def services(self):
|
def services(self):
|
||||||
from app.models.service import Service
|
from app.models.service import Services
|
||||||
return [
|
return Services(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