mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-26 06:09:41 +00:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
09aecc36b3 | |||
348c5946dd | |||
5603853896 | |||
82b7fe7000 | |||
92679061e2 | |||
67e4e96d85 | |||
df32e5ed37 | |||
e3796f2204 | |||
03f0a4c363 | |||
a3a4a8d091 | |||
772c0c89b5 | |||
d614d13136 | |||
93ce63b1d4 | |||
4f2b42dc08 | |||
5c05a988a5 | |||
2aff4e52f0 | |||
bdc92163c3 | |||
9abf549ed4 | |||
057c58b709 |
@ -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
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class GoogleLoginMixin(object):
|
|||||||
user_info = response.json()
|
user_info = response.json()
|
||||||
email = user_info['email']
|
email = user_info['email']
|
||||||
first_name = user_info['given_name']
|
first_name = user_info['given_name']
|
||||||
last_name = user_info['family_name']
|
last_name = user_info['family_name'] if 'family_name' in user_info and user_info['family_name'] else user_info['given_name']
|
||||||
profile_picture = user_info['picture']
|
profile_picture = user_info['picture']
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
@ -760,7 +760,7 @@ class ForceUpdateViewSet(GenericViewSet, mixins.CreateModelMixin):
|
|||||||
:param kwargs:
|
:param kwargs:
|
||||||
:return: success message
|
:return: success message
|
||||||
"""
|
"""
|
||||||
if ForceUpdate.objects.all().count() >= 2:
|
if ForceUpdate.objects.all().count() >= 4:
|
||||||
return custom_error_response(ERROR_CODE['2080'], response_status=status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(ERROR_CODE['2080'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
obj_data = [ForceUpdate(**item) for item in request.data]
|
obj_data = [ForceUpdate(**item) for item in request.data]
|
||||||
try:
|
try:
|
||||||
|
@ -96,8 +96,8 @@ ERROR_CODE = {
|
|||||||
"2067": "Action not allowed. User type missing.",
|
"2067": "Action not allowed. User type missing.",
|
||||||
"2068": "No guardian associated with this junior",
|
"2068": "No guardian associated with this junior",
|
||||||
"2069": "Invalid user type",
|
"2069": "Invalid user type",
|
||||||
"2070": "You do not find as a guardian",
|
"2070": "You are not registered as a guardian in our system. Please try again as junior.",
|
||||||
"2071": "You do not find as a junior",
|
"2071": "You are not registered as a junior in our system. Please try again as guardian.",
|
||||||
"2072": "You can not approve or reject this task because junior does not exist in the system",
|
"2072": "You can not approve or reject this task because junior does not exist in the system",
|
||||||
"2073": "You can not approve or reject this junior because junior does not exist in the system",
|
"2073": "You can not approve or reject this junior because junior does not exist in the system",
|
||||||
"2074": "You can not complete this task because you does not exist in the system",
|
"2074": "You can not complete this task because you does not exist in the system",
|
||||||
|
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)
|
||||||
|
@ -56,7 +56,14 @@ if ENV in ['dev', 'qa', 'stage']:
|
|||||||
# Add more trusted origins as needed
|
# Add more trusted origins as needed
|
||||||
]
|
]
|
||||||
if ENV == "prod":
|
if ENV == "prod":
|
||||||
CORS_ALLOWED_ORIGINS = []
|
CORS_ALLOWED_ORIGINS = [
|
||||||
|
# backend base url
|
||||||
|
"https://prod-api.zodbank.com",
|
||||||
|
|
||||||
|
# frontend url
|
||||||
|
"https://web.zodbank.com",
|
||||||
|
# Add more trusted origins as needed
|
||||||
|
]
|
||||||
|
|
||||||
# allow all host
|
# allow all host
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
@ -137,10 +144,11 @@ REST_FRAMEWORK = {
|
|||||||
}
|
}
|
||||||
# define jwt token
|
# define jwt token
|
||||||
SIMPLE_JWT = {
|
SIMPLE_JWT = {
|
||||||
'ACCESS_TOKEN_LIFETIME': timedelta(hours=2, minutes=59, seconds=59, microseconds=999999),
|
'ACCESS_TOKEN_LIFETIME': timedelta(hours=3, minutes=59, seconds=59, microseconds=999999),
|
||||||
'REFRESH_TOKEN_LIFETIME': timedelta(hours=71, minutes=59, seconds=59, microseconds=999999),
|
'REFRESH_TOKEN_LIFETIME': timedelta(days=364, hours=23, minutes=59, seconds=59, microseconds=999999),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
@ -200,7 +208,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
# database query logs settings
|
# database query logs settings
|
||||||
# Allows us to check db hits
|
# Allows us to check db hits
|
||||||
# useful to optimize db query and hit
|
# useful to optimize db query and hit
|
||||||
LOGGING = {
|
LOGGING1 = {
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"filters": {
|
"filters": {
|
||||||
"require_debug_true": {
|
"require_debug_true": {
|
||||||
|
Reference in New Issue
Block a user