mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
Merge pull request #363 from KiwiTechLLC/ZBKBCK-56
modified user notification setting, added optional value for sms notitication as false, added fixture file for faq's
This commit is contained in:
@ -387,7 +387,7 @@ class UpdateUserNotificationSerializer(serializers.ModelSerializer):
|
|||||||
defaults={
|
defaults={
|
||||||
'push_notification': validated_data.get('push_notification'),
|
'push_notification': validated_data.get('push_notification'),
|
||||||
'email_notification': validated_data.get('email_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
|
return instance
|
||||||
|
|
||||||
|
|||||||
112
fixtures/faq.json
Normal file
112
fixtures/faq.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -19,6 +19,7 @@ from base.pagination import CustomPageNumberPagination
|
|||||||
"""Django app import"""
|
"""Django app import"""
|
||||||
from drf_yasg.utils import swagger_auto_schema
|
from drf_yasg.utils import swagger_auto_schema
|
||||||
from drf_yasg import openapi
|
from drf_yasg import openapi
|
||||||
|
from django.core.management import call_command
|
||||||
from drf_yasg.views import get_schema_view
|
from drf_yasg.views import get_schema_view
|
||||||
# Import guardian's model,
|
# Import guardian's model,
|
||||||
# Import junior's model,
|
# Import junior's model,
|
||||||
@ -813,7 +814,7 @@ class FAQViewSet(GenericViewSet, mixins.CreateModelMixin,
|
|||||||
http_method_names = ['get', 'post']
|
http_method_names = ['get', 'post']
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return FAQ.objects.all()
|
return FAQ.objects.filter(status=1).order_by('id')
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -823,6 +824,10 @@ class FAQViewSet(GenericViewSet, mixins.CreateModelMixin,
|
|||||||
:param kwargs:
|
:param kwargs:
|
||||||
:return: success message
|
: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]
|
obj_data = [FAQ(**item) for item in request.data]
|
||||||
try:
|
try:
|
||||||
FAQ.objects.bulk_create(obj_data)
|
FAQ.objects.bulk_create(obj_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user