Merge pull request #365 from KiwiTechLLC/qa

Qa into stage
This commit is contained in:
Abu Talib
2023-11-08 19:13:44 +05:30
committed by GitHub
3 changed files with 119 additions and 2 deletions

View File

@ -387,7 +387,7 @@ class UpdateUserNotificationSerializer(serializers.ModelSerializer):
defaults={
'push_notification': validated_data.get('push_notification'),
'email_notification': validated_data.get('email_notification'),
'sms_notification': validated_data.get('sms_notification'),
'sms_notification': validated_data.get('sms_notification', False),
})
return instance

112
fixtures/faq.json Normal file
View File

@ -0,0 +1,112 @@
[
{
"model": "junior.faq",
"pk": 1,
"fields": {
"question": "What is ZOD ?",
"description": "We are a future neobank for under 18. We aim to provide children with the ability to use debit cards under the watchfull eye of their parents.",
"status": 1,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 2,
"fields": {
"question": "What is financial literacy ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 3,
"fields": {
"question": "How can we win with Zod ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 4,
"fields": {
"question": "What is a budget ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 5,
"fields": {
"question": "What is the difference between stocks and bonds ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 6,
"fields": {
"question": "What is compound interest ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 7,
"fields": {
"question": "What is diversification ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 8,
"fields": {
"question": "What is a 401(k) ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 9,
"fields": {
"question": "What is an emergency fund ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
},
{
"model": "junior.faq",
"pk": 10,
"fields": {
"question": "What is a mortgage ?",
"description": "",
"status": 2,
"created_at": "2023-11-08T12:32:55.291Z",
"updated_at": "2023-11-08T12:32:55.291Z"
}
}
]

View File

@ -19,6 +19,7 @@ from base.pagination import CustomPageNumberPagination
"""Django app import"""
from drf_yasg.utils import swagger_auto_schema
from drf_yasg import openapi
from django.core.management import call_command
from drf_yasg.views import get_schema_view
# Import guardian's model,
# Import junior's model,
@ -813,7 +814,7 @@ class FAQViewSet(GenericViewSet, mixins.CreateModelMixin,
http_method_names = ['get', 'post']
def get_queryset(self):
return FAQ.objects.all()
return FAQ.objects.filter(status=1).order_by('id')
def create(self, request, *args, **kwargs):
"""
@ -823,6 +824,10 @@ class FAQViewSet(GenericViewSet, mixins.CreateModelMixin,
:param kwargs:
:return: success message
"""
load_fixture = request.query_params.get('load_fixture')
if load_fixture:
call_command('loaddata', 'fixtures/faq.json')
return custom_response(SUCCESS_CODE["3045"], response_status=status.HTTP_200_OK)
obj_data = [FAQ(**item) for item in request.data]
try:
FAQ.objects.bulk_create(obj_data)