diff --git a/apps/spotlight/urls.py b/apps/spotlight/urls.py index ea8a25f..508aba7 100644 --- a/apps/spotlight/urls.py +++ b/apps/spotlight/urls.py @@ -14,11 +14,12 @@ """ from django.urls import path -from apps.spotlight.views import QueryView, RecentQueryView +from apps.spotlight.views import HelpQueryView, QueryView, RecentQueryView urlpatterns = [ path('recent_queries/', RecentQueryView.as_view(), name='recent-queries'), path('query/', QueryView.as_view(), name='query'), + path('help/', HelpQueryView.as_view(), name='help'), ] diff --git a/apps/spotlight/views.py b/apps/spotlight/views.py index 53111a2..312aeaa 100644 --- a/apps/spotlight/views.py +++ b/apps/spotlight/views.py @@ -6,7 +6,7 @@ from apps.spotlight.models import Query from apps.spotlight.serializers import QuerySerializer -from .service import QueryService +from .service import HelpService, QueryService # Create your views here. @@ -69,3 +69,11 @@ def post(self, request, *args, **kwargs): user_id=1 ) return JsonResponse(data=suggestions["suggestions"]) + + +class HelpQueryView(generics.CreateAPIView): + def post(self, request, *args, **kwargs): + payload = json.loads(request.body) + user_query = payload["query"] + support_response = HelpService.get_support_response(user_query=user_query) + return JsonResponse(data={"message": support_response})