Skip to content

Commit

Permalink
Merge pull request #73 from arthur-schnitzler/66-imprint
Browse files Browse the repository at this point in the history
added imprint and about views
  • Loading branch information
csae8092 authored Jan 11, 2024
2 parents a5b6832 + 7f74a15 commit 6e42254
Show file tree
Hide file tree
Showing 9 changed files with 521 additions and 14 deletions.
8 changes: 1 addition & 7 deletions apis_core/apis_entities/base_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class MyBaseFilter(django_filters.FilterSet):

def construct_lookup(self, value):
"""
Parses user input for wildcards and returns a tuple containing the interpreted django lookup string and the trimmed value
Expand All @@ -17,24 +16,19 @@ def construct_lookup(self, value):
"""

if value.startswith("*") and not value.endswith("*"):

value = value[1:]
return "__iendswith", value

elif not value.startswith("*") and value.endswith("*"):

value = value[:-1]
return "__istartswith", value

elif value.startswith('"') and value.endswith('"'):

value = value[1:-1]
return "__iexact", value

else:

if value.startswith("*") and value.endswith("*"):

value = value[1:-1]

return "__icontains", value
Expand All @@ -44,4 +38,4 @@ def name_label_filter(self, queryset, name, value):
lookup, value = self.construct_lookup(value)
queryset_related_label = queryset.filter(**{"label__label" + lookup: value})
queryset_self_name = queryset.filter(**{name + lookup: value})
return (queryset_related_label | queryset_self_name).distinct().all()
return (queryset_related_label | queryset_self_name).distinct().all()
Loading

0 comments on commit 6e42254

Please sign in to comment.