Skip to content

Commit

Permalink
make uiconfig/ endpoint obey active setting on uiitems and uigroups; …
Browse files Browse the repository at this point in the history
…ie filter inactive from results (#356)
  • Loading branch information
hburgund committed Nov 6, 2017
1 parent a4442c4 commit 3b6508b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions roundware/api2/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Meta:
class UIConfigFilterSet(django_filters.FilterSet):
project_id = django_filters.NumberFilter()
ui_mode = django_filters.TypedChoiceFilter(choices=UIGroup.UI_MODES)
active = django_filters.TypedChoiceFilter(choices=BOOLEAN_CHOICES, coerce=strtobool)

class Meta:
model = UIGroup
Expand Down
3 changes: 1 addition & 2 deletions roundware/api2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def to_representation(self, obj):
result['header_display_text'] = result['header_text_loc']
del result['header_text_loc']

uiitems = UIItem.objects.filter(ui_group=result["id"])
uiitems = UIItem.objects.filter(ui_group=result["id"], active=True)

# filter listen display_items to one per tag_id; speak returns all
if self.context["mode"] == "listen":
Expand Down Expand Up @@ -465,7 +465,6 @@ def to_representation(self, obj):
if self.context["mode"] == "listen":
result['parent_id'] = None


return result


Expand Down
1 change: 1 addition & 0 deletions roundware/api2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ def uiconfig(self, request, pk=None):
except:
raise ParseError("Session not found")
params["project_id"] = pk
params['active'] = 'true'
params['ui_mode'] = 'listen'
uigroups_listen = UIGroupFilterSet(params)
serializer_listen = serializers.UIConfigSerializer(uigroups_listen,
Expand Down

0 comments on commit 3b6508b

Please sign in to comment.