Skip to content

Commit

Permalink
make tag browsing case-insensitive and unique
Browse files Browse the repository at this point in the history
  • Loading branch information
quimmrc committed Dec 17, 2024
1 parent 534d66e commit 97d22fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def search_view_helper(request):
request.user.profile.use_compact_mode = request_preference
request.user.profile.save()

# Parpare variables for map view (prepare some URLs for loading sounds and providing links to map)
# Prepare variables for map view (prepare some URLs for loading sounds and providing links to map)
open_in_map_url = None
map_mode_query_results_cache_key = None
map_bytearray_url = ''
Expand Down Expand Up @@ -152,7 +152,7 @@ def search_view_helper(request):
'tags_mode': sqp.tags_mode_active(),
'query_time': results.q_time
}))

# Compile template variables
return {
'sqp': sqp,
Expand Down
7 changes: 4 additions & 3 deletions tags/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@


def tags(request, multiple_tags=None):

if multiple_tags:
multiple_tags = multiple_tags.split('/')
else:
multiple_tags = []
multiple_tags = sorted([x for x in multiple_tags if x])
#Make all tags lower-cased and unique to get a case-insensitive search filter and shortened browse url
multiple_tags = sorted(set([x.lower() for x in multiple_tags if x]))
if multiple_tags:
# We re-write tags as query filter and redirect
search_filter = "+".join('tag:"' + tag + '"' for tag in multiple_tags)
Expand All @@ -51,7 +52,7 @@ def tags(request, multiple_tags=None):
if pack_flt is not None:
# If username is passed as a GET parameter, add it as well to the filter
search_filter += f'+grouping_pack:{pack_flt}'

return HttpResponseRedirect(f"{reverse('tags')}?f={search_filter}")
else:
# Share same view code as for the search view, but "tags mode" will be on
Expand Down

0 comments on commit 97d22fe

Please sign in to comment.