From 37d191eef8685cc44b36bcecc1ea19a68dab086f Mon Sep 17 00:00:00 2001 From: jain Date: Tue, 29 Aug 2023 10:41:44 +0530 Subject: [PATCH] add message for blank search --- base/messages.py | 3 ++- junior/views.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/messages.py b/base/messages.py index 54c427f..5a6e2e8 100644 --- a/base/messages.py +++ b/base/messages.py @@ -111,7 +111,8 @@ ERROR_CODE = { "2080": "Can not add App version", "2081": "A junior can only be associated with a maximum of 3 guardian", # guardian code not exist - "2082": "Guardian code does not exist" + "2082": "Guardian code does not exist", + "2083": "Search should not be blank" } """Success message code""" diff --git a/junior/views.py b/junior/views.py index 5ca50e0..a560f4d 100644 --- a/junior/views.py +++ b/junior/views.py @@ -223,6 +223,8 @@ class AddJuniorAPIView(viewsets.ModelViewSet): junior.guardian_code.append(guardian.guardian_code) else: return "Max" + if junior.guardian_code_status and ('-' in junior.guardian_code_status): + junior.guardian_code_status.remove('-') if not junior.guardian_code_status: junior.guardian_code_status = [str(NUMBER['two'])] else: @@ -355,6 +357,8 @@ class JuniorTaskListAPIView(viewsets.ModelViewSet): try: status_value = self.request.GET.get('status') search = self.request.GET.get('search') + if search.strip() == '': + return custom_error_response(ERROR_CODE['2083'], response_status=status.HTTP_400_BAD_REQUEST) if search and str(status_value) == '0': # search with title and for all task list queryset = JuniorTask.objects.filter(junior__auth=request.user,