Skip to content

Commit

Permalink
Refactor the code from getServices()
Browse files Browse the repository at this point in the history
  • Loading branch information
xispa committed Nov 5, 2024
1 parent a4d9e59 commit df4bf14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/senaite/core/content/analysisprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,11 @@ def getServices(self, active_only=True):
:returns: List of analysis service objects
"""
services = []
for uid in self.getServiceUIDs():
obj = api.get_object(uid)
if not active_only or api.is_active(obj):
services.append(obj)
return services
services = map(api.get_object, self.getServiceUIDs())
if active_only:
# filter out inactive services
services = filter(api.is_active, services)
return list(services)

@security.protected(permissions.ModifyPortalContent)
def setServices(self, value):
Expand Down
11 changes: 5 additions & 6 deletions src/senaite/core/content/sampletemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,11 @@ def getServices(self, active_only=True):
:returns: List of analysis service objects
"""
services = []
for uid in self.getServiceUIDs():
obj = api.get_object(uid)
if not active_only or api.is_active(obj):
services.append(obj)
return services
services = map(api.get_object, self.getServiceUIDs())
if active_only:
# filter out inactive services
services = filter(api.is_active, services)
return list(services)

@security.protected(permissions.ModifyPortalContent)
def setServices(self, value):
Expand Down

0 comments on commit df4bf14

Please sign in to comment.