From ffc95019f046c811563da1bf254c18ae78a0f75f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 30 Dec 2024 22:07:42 -0800 Subject: [PATCH] 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 Reviewed-by: Joseph Nuthalapati --- plinth/app.py | 11 ----------- plinth/views.py | 7 +++++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/plinth/app.py b/plinth/app.py index 46ef1c49c..aa5db71f4 100644 --- a/plinth/app.py +++ b/plinth/app.py @@ -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. diff --git a/plinth/views.py b/plinth/views.py index 709a87980..803262126 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -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