Skip to content

Commit

Permalink
use regex for filtering narrative
Browse files Browse the repository at this point in the history
  • Loading branch information
bimac committed Jan 9, 2025
1 parent 358b790 commit b7f77f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions alyx/actions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ def lookups(self, request, model_admin):
)

def queryset(self, request, queryset):
regex_string = r'^(?:[ ]*|auto-generated session)$'
if self.value() == 'narrative':
return queryset.exclude(narrative__in=['', 'auto-generated session'])
return queryset.exclude(narrative__regex=regex_string)
if self.value() == 'no_narrative':
return queryset.filter(narrative__in=['', 'auto-generated session'])
return queryset.filter(narrative__regex=regex_string)
elif self.value is None:
return queryset.all()

Expand Down

0 comments on commit b7f77f9

Please sign in to comment.