Skip to content

Commit

Permalink
Support fields query param
Browse files Browse the repository at this point in the history
  • Loading branch information
stevelacey authored and wadewilliams committed Oct 25, 2021
1 parent 0bf8ae4 commit f37172e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion worf/views/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ def paginated_results(self):
except EmptyPage:
return []

def specific_fields(self, result):
fields = self.bundle.get("fields", [])
if fields:
return {key: value for key, value in result.items() if key in fields}
return result

def parse_sort(self, fields):
return [self.transform_sort(field) for field in fields]

Expand All @@ -193,7 +199,8 @@ def serialize(self):

payload = {
str(self.name): [
serializer.read(instance) for instance in self.paginated_results()
self.specific_fields(serializer.read(instance))
for instance in self.paginated_results()
]
}

Expand Down

0 comments on commit f37172e

Please sign in to comment.