diff options
Diffstat (limited to 'lib/srtgui/typeaheads.py')
-rw-r--r-- | lib/srtgui/typeaheads.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/srtgui/typeaheads.py b/lib/srtgui/typeaheads.py index e32c16ad..800e9b0e 100644 --- a/lib/srtgui/typeaheads.py +++ b/lib/srtgui/typeaheads.py @@ -19,6 +19,8 @@ import subprocess from srtgui.widgets import ToasterTypeAhead +from orm.models import RecipeTable + from django.urls import reverse from django.core.cache import cache @@ -184,3 +186,27 @@ class GitRevisionTypeAhead(ToasterTypeAhead): 'detail': '[ %s ]' % str(rev)}) return results + + +class RecipeTypeAhead(ToasterTypeAhead): + """ Typeahead for all the recipes """ + def apply_search(self, search_term, cve, request): + + recipes = RecipeTable.objects.all().order_by("recipe_name") + + primary_results = recipes.filter(recipe_name__icontains=search_term) + + results = [] + + for recipe in list(primary_results): + + detail = '' + needed_fields = { + 'id': recipe.pk, + 'name': recipe.recipe_name, + 'detail': detail, + } + + results.append(needed_fields) + + return results |