apps: Only show app tags all the tags in apps page search box

- Earlier tags of all the apps from help, system, and apps pages were shown.
Now, only show tags from apps in the apps page.

- There is no need to override language since menu.tags which is sames as
info.tags is already a list of untranslated strings.

Tests:

- List of tags is shown in the dropdown when tag search bar is clicked. This
list contains translated tags when language is set to Spanish. The sort order is
per the translated locale.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa 2024-12-30 22:07:42 -08:00 committed by Joseph Nuthalapati
parent 7cad8e47be
commit ffc95019f0
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
2 changed files with 5 additions and 13 deletions

View File

@ -543,17 +543,6 @@ class Info(FollowerComponent):
for tag in self._tags
]
@classmethod
def list_tags(self) -> list[str]:
"""Return a list of untranslated tags."""
tags: set[str] = set()
from django.utils.translation import override
with override(language=None):
for app in App.list():
tags.update((str(tag) for tag in app.info.tags))
return list(tags)
class EnableState(LeaderComponent):
"""A component to hold the enable state of an app using a simple flag.

View File

@ -226,8 +226,11 @@ class AppsIndexView(TemplateView):
context['tags'] = tags
# Sorted tags by localized string
context['all_tags'] = sorted(app_module.Info.list_tags(),
key=lambda tag: _(tag))
all_tags = set()
for menu_item in menu_items:
all_tags.update(menu_item.tags or [])
context['all_tags'] = sorted(all_tags, key=lambda tag: _(tag))
context['menu_items'] = self._pick_menu_items(menu_items, tags)
return context