Skip to content

Commit

Permalink
fix(scope): allows users to filter on integer field (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarreau authored Apr 12, 2023
1 parent 2c50bb4 commit 006ce6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions django_forest/tests/resources/views/list/test_list_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
'operator': 'contains',
'value': 'color'
},
{
'field': 'id',
'operator': 'greater_than',
'value': 0
},
]
},
'dynamicScopesValues': {}
Expand All @@ -44,6 +49,11 @@
'operator': 'contains',
'value': 'color'
},
{
'field': 'id',
'operator': 'less_than',
'value': 0
},
{
'field': 'question_text',
'operator': 'contains',
Expand Down
2 changes: 1 addition & 1 deletion django_forest/utils/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _format_dynamic_values(user_id, collection_scope):
try:
scope = collection_scope['scope']
for condition in scope['filter']['conditions']:
if condition['value'].startswith('$currentUser'):
if str(condition['value']).startswith('$currentUser'):
condition['value'] = scope['dynamicScopesValues']['users'][user_id][condition['value']]
return scope['filter']
except Exception:
Expand Down

0 comments on commit 006ce6c

Please sign in to comment.