diff --git a/account/serializers.py b/account/serializers.py index 284ae09..5686931 100644 --- a/account/serializers.py +++ b/account/serializers.py @@ -155,9 +155,9 @@ class AdminLoginSerializer(serializers.ModelSerializer): ).only('id', 'first_name', 'last_name', 'email', 'is_superuser').first() if not user: - raise serializers.ValidationError({'details': ERROR_CODE['2063']}) + raise serializers.ValidationError({'details': ERROR_CODE['2002']}) elif not user.check_password(attrs['password']): - raise serializers.ValidationError({'details': ERROR_CODE['2031']}) + raise serializers.ValidationError({'details': ERROR_CODE['2002']}) self.context.update({'user': user}) return attrs diff --git a/account/views.py b/account/views.py index 853c43a..80530ad 100644 --- a/account/views.py +++ b/account/views.py @@ -335,9 +335,9 @@ class UserLogin(viewsets.ViewSet): ).only('id', 'first_name', 'last_name', 'email', 'is_superuser').first() if not user: - return custom_error_response(ERROR_CODE["2063"], response_status=status.HTTP_400_BAD_REQUEST) + return custom_error_response(ERROR_CODE["2002"], response_status=status.HTTP_400_BAD_REQUEST) elif not user.check_password(password): - return custom_error_response(ERROR_CODE["2031"], response_status=status.HTTP_400_BAD_REQUEST) + return custom_error_response(ERROR_CODE["2002"], response_status=status.HTTP_400_BAD_REQUEST) serializer = SuperUserSerializer(user) return custom_response(SUCCESS_CODE['3003'], serializer.data, response_status=status.HTTP_200_OK) diff --git a/base/messages.py b/base/messages.py index cf85f2b..f7d36dc 100644 --- a/base/messages.py +++ b/base/messages.py @@ -23,15 +23,15 @@ ERROR_CODE_REQUIRED = { # Error code ERROR_CODE = { - "2000": "Email not found.", + "2000": "Invalid email address. Please enter a registered email.", "2001": "This is your existing password. Please choose other one", - "2002": "Invalid login credentials.", + "2002": "Invalid username or password.", "2003": "An account already exists with this email address.", "2004": "User not found.", "2005": "Your account has been activated.", "2006": "Your account is not activated.", "2007": "Your account already activated.", - "2008": "Invalid OTP.", + "2008": "The OTP entered is not correct.", "2009": "The user provided cannot be found or the reset password token has become invalid/timed out.", "2010": "Invalid Link.", "2011": "Your profile has not been completed yet.", @@ -54,7 +54,7 @@ ERROR_CODE = { "2026": "New password should not same as old password", "2027": "data should contain `identityToken`", "2028": "You are not authorized person to sign up on this platform", - "2029": "Validity of otp verification is expired", + "2029": "Validity of otp verification has expired. Please request a new one.", "2030": "Use correct user type and token", # invalid password "2031": "Invalid password", @@ -111,7 +111,7 @@ SUCCESS_CODE = { # Success code for link verified "3005": "Your account is deleted successfully.", # Success code for password reset - "3006": "Your password has been reset successfully.", + "3006": "Password reset successful. You can now log in with your new password.", # Success code for password update "3007": "Your password has been changed successfully.", # Success code for valid link @@ -124,8 +124,8 @@ SUCCESS_CODE = { "3012": "Phone OTP Verified successfully", "3013": "Valid Guardian code", "3014": "Password has been updated successfully.", - "3015": "Verification code sent on your email.", - "3016": "Send otp on your Email successfully", + "3015": "Verification code has been sent on your email.", + "3016": "An OTP has been sent on your email.", "3017": "Profile image update successfully", "3018": "Task created successfully", "3019": "Support Email sent successfully", diff --git a/web_admin/views/auth.py b/web_admin/views/auth.py index 0273a08..fae973e 100644 --- a/web_admin/views/auth.py +++ b/web_admin/views/auth.py @@ -33,7 +33,7 @@ class ForgotAndResetPasswordViewSet(GenericViewSet): if serializer.is_valid(): serializer.save() return custom_response(SUCCESS_CODE['3015']) - return custom_error_response(ERROR_CODE['2063'], status.HTTP_400_BAD_REQUEST) + return custom_error_response(ERROR_CODE['2000'], status.HTTP_400_BAD_REQUEST) @action(methods=['post'], url_name='verify-otp', url_path='verify-otp', detail=False, serializer_class=AdminVerifyOTPSerializer) @@ -45,7 +45,7 @@ class ForgotAndResetPasswordViewSet(GenericViewSet): serializer = self.serializer_class(data=request.data) if serializer.is_valid(): return custom_response(SUCCESS_CODE['3011']) - return custom_error_response(ERROR_CODE['2063'], status.HTTP_400_BAD_REQUEST) + return custom_error_response(ERROR_CODE['2008'], status.HTTP_400_BAD_REQUEST) @action(methods=['post'], url_name='create-password', url_path='create-password', detail=False, serializer_class=AdminCreatePasswordSerializer) @@ -59,5 +59,5 @@ class ForgotAndResetPasswordViewSet(GenericViewSet): user = USER.objects.filter(email=serializer.validated_data.get('email')).first() user.set_password(serializer.validated_data.get('new_password')) user.save() - return custom_response(SUCCESS_CODE['3007']) + return custom_response(SUCCESS_CODE['3006']) return custom_error_response(ERROR_CODE['2064'], status.HTTP_400_BAD_REQUEST) diff --git a/web_admin/views/user_management.py b/web_admin/views/user_management.py index 20184cd..3bd8f64 100644 --- a/web_admin/views/user_management.py +++ b/web_admin/views/user_management.py @@ -55,11 +55,12 @@ class UserManagementViewSet(GenericViewSet, mixins.ListModelMixin, :return: """ queryset = self.get_queryset() - count = queryset.count() + queryset = queryset.filter( + (Q(junior_profile__is_verified=True) | Q(guardian_profile__is_verified=True))) paginator = self.pagination_class() paginated_queryset = paginator.paginate_queryset(queryset, request) serializer = self.serializer_class(paginated_queryset, many=True) - return custom_response(None, data=serializer.data, count=count) + return custom_response(None, data=serializer.data, count=queryset.count()) def retrieve(self, request, *args, **kwargs): """ @@ -69,7 +70,7 @@ class UserManagementViewSet(GenericViewSet, mixins.ListModelMixin, :return: user details """ if self.request.query_params.get('user_type') not in [dict(USER_TYPE).get('1'), dict(USER_TYPE).get('2')]: - return custom_error_response('Action not allowed', status.HTTP_400_BAD_REQUEST) + return custom_error_response(ERROR_CODE['2067'], status.HTTP_400_BAD_REQUEST) queryset = self.queryset if self.request.query_params.get('user_type') == dict(USER_TYPE).get('2'): queryset = queryset.filter(guardian_profile__user__id=kwargs['pk'])