Skip to content

Commit

Permalink
Task: Add method to get all services by feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
jairojair committed Sep 18, 2018
1 parent 35ed261 commit 15737ea
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion featuren/models/feature.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from apistar import types, validators
from orator import Model
from orator import Model, accessor
from models.features_service import FeaturesServices

import logging
Expand Down Expand Up @@ -33,7 +33,22 @@ class Feature(Model):

__fillable__ = ["id", "version", "enabled", "deny"]

__appends__ = ["services"]

@accessor
def services(self):
"""
Method to get all services by feature.
"""
services = FeaturesServices.all().where("feature_id", self.id)
services.transform(lambda item: item.service_id)

return services.serialize()

def update_services(self, services):
"""
Method to update the list of available services for feature.
"""

try:

Expand Down

0 comments on commit 15737ea

Please sign in to comment.