Compare commits

..

113 Commits

Author SHA1 Message Date
38252ac5ea Merge pull request #389 from KiwiTechLLC/dev
Dev into qa
2024-03-07 12:40:47 +05:30
8fb627ec03 fixed expire time 2024-03-07 12:40:01 +05:30
c3aa31788f Merge pull request #388 from KiwiTechLLC/ZBKBCK-56
set refresh token time to 365 days
2024-03-06 16:32:16 +05:30
09aecc36b3 set refresh token time to 365 days 2024-03-06 16:21:19 +05:30
348c5946dd token time changed to 1m 2024-03-04 19:32:46 +05:30
8464fbbe7b Merge pull request #385 from KiwiTechLLC/dev
increased count for version objects
2023-12-11 14:28:46 +05:30
5603853896 increased count for version objects 2023-12-11 14:25:24 +05:30
85871592ca Merge pull request #382 from KiwiTechLLC/dev
updated prod base url
2023-12-07 12:01:20 +05:30
82b7fe7000 updated prod base url 2023-12-07 12:00:16 +05:30
51341529d9 Merge pull request #379 from KiwiTechLLC/dev
updated frontend prod url
2023-12-06 16:18:52 +05:30
92679061e2 updated frontend prod url 2023-12-06 16:17:41 +05:30
d7f198c15f Merge pull request #376 from KiwiTechLLC/dev
added prod link and base url
2023-12-04 17:56:07 +05:30
67e4e96d85 added prod link and base url 2023-12-04 17:54:56 +05:30
236d8ffd85 Merge pull request #373 from KiwiTechLLC/dev
Dev into qa
2023-12-04 17:08:29 +05:30
df32e5ed37 added prod link and base url 2023-12-04 17:05:16 +05:30
e3796f2204 auth token expiry set to 1 min 2023-11-27 12:50:02 +05:30
03f0a4c363 Merge branch 'dev' of https://github.com/KiwiTechLLC/ZODBank-Backend into dev 2023-11-27 12:46:42 +05:30
a3a4a8d091 auth token expiry set to 1 min 2023-11-27 12:43:17 +05:30
595212e58f Merge pull request #370 from KiwiTechLLC/dev
Dev into qa
2023-11-16 17:34:11 +05:30
772c0c89b5 Merge pull request #369 from KiwiTechLLC/ZBKBCK-56
added optional last name in google login
2023-11-16 17:33:14 +05:30
d614d13136 added optional last name in google login 2023-11-16 17:32:34 +05:30
5665389db4 Merge pull request #367 from KiwiTechLLC/dev
Dev into qa
2023-11-16 17:09:33 +05:30
93ce63b1d4 Merge pull request #366 from KiwiTechLLC/ZBKBCK-56
changed message
2023-11-16 17:08:56 +05:30
4f2b42dc08 changed message 2023-11-16 17:07:46 +05:30
aa9459e3f7 Merge pull request #364 from KiwiTechLLC/dev
Dev into qa
2023-11-08 19:12:48 +05:30
5c05a988a5 new line in faq_json file 2023-11-08 18:54:54 +05:30
2aff4e52f0 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
2023-11-08 18:50:38 +05:30
bdc92163c3 added fixture file for faq's 2023-11-08 18:47:28 +05:30
9abf549ed4 modified user notification setting, added optional value for sms notification as false 2023-11-08 15:02:23 +05:30
f04016fb45 Merge pull request #361 from KiwiTechLLC/dev
Dev into qa
2023-10-27 14:45:46 +05:30
057c58b709 Merge pull request #360 from KiwiTechLLC/ZBKBCK-55
added status for login and sign up from google and apple
2023-10-27 12:23:25 +05:30
b1d8949b08 added status for login and sign up from google and apple 2023-10-27 12:05:47 +05:30
ced3db76c1 Merge pull request #358 from KiwiTechLLC/dev
Dev
2023-10-06 18:19:55 +05:30
801bc45bc5 Merge pull request #357 from KiwiTechLLC/ZBKBCK-54
to user type added
2023-10-06 18:12:47 +05:30
d1927b24ee to user type added 2023-10-06 18:10:56 +05:30
62e5e4c062 Merge pull request #355 from KiwiTechLLC/dev
Dev into qa
2023-10-06 17:57:33 +05:30
012d93f70f Merge pull request #354 from KiwiTechLLC/ZBKBCK-54
added to user type as per required changes, handled apple signup for existing users
2023-10-06 17:55:01 +05:30
a1f9f93654 added to user type as per required changes, handled apple signup for existing users 2023-10-06 17:29:41 +05:30
ac372e62af Merge pull request #352 from KiwiTechLLC/dev
Dev into qa
2023-10-05 17:46:56 +05:30
652fe9e680 Merge pull request #351 from KiwiTechLLC/ZBKBCK-54
fixed user notificatio setting issue
2023-10-05 17:43:19 +05:30
13665f4c9a fixed user notificatio setting issue 2023-10-05 17:38:57 +05:30
810752793b Merge pull request #349 from KiwiTechLLC/dev
Dev into qa
2023-10-05 14:56:04 +05:30
bf5453c7b7 Merge pull request #348 from KiwiTechLLC/ZBKBCK-54
fixed login into another device issue
2023-10-05 13:24:56 +05:30
6e3166967e fixed login into another device issue 2023-10-05 13:07:42 +05:30
49b264e918 Merge pull request #346 from KiwiTechLLC/dev
Dev into qa
2023-10-03 19:12:52 +05:30
47a00f313a Merge pull request #345 from KiwiTechLLC/ZBKBCK-54
added mail for user activation, handled fcm token for deleted user
2023-10-03 18:57:55 +05:30
ad4d782e72 added mail for user activation, handled fcm token for deleted user 2023-10-03 18:54:47 +05:30
742ee0ee67 Merge pull request #343 from KiwiTechLLC/dev
Dev into qa
2023-09-29 18:27:22 +05:30
8050e70cf7 Merge pull request #342 from KiwiTechLLC/ZBKBCK-54
handled deactivated users for social login
2023-09-29 16:11:08 +05:30
18a53e1c48 handled deactivated users for social login 2023-09-29 16:09:22 +05:30
f1333491e0 Merge pull request #341 from KiwiTechLLC/ZBKBCK-54
notification mark as read api modified for clear all, list sorting set to updated at field, added same field
2023-09-29 15:09:47 +05:30
bd7eddb275 notification mark as read api modified for clear all, list sorting set to updated at field, added same field 2023-09-29 14:58:06 +05:30
4c34c2496b Merge pull request #340 from KiwiTechLLC/ZBKBCK-54
notification create modified to update or create
2023-09-28 19:35:16 +05:30
e121c92fb4 notification create modified to update or create 2023-09-28 19:09:57 +05:30
18143e0219 modified send push method 2023-09-27 19:31:09 +05:30
251a912948 revert access token time to 3 hrs 2023-09-27 12:36:28 +05:30
f7bb83cebb added notification type in serializer 2023-09-26 19:11:04 +05:30
994e9a270e Merge pull request #339 from KiwiTechLLC/ZBKBCK-54
added notification type in push data
2023-09-26 17:27:10 +05:30
32c35f8649 added notification type in push data 2023-09-26 17:24:40 +05:30
ea02d7f5bb token expire time 1 min for testing 2023-09-25 11:45:50 +05:30
648628d3ea Merge branch 'dev' of https://github.com/KiwiTechLLC/ZODBank-Backend into dev 2023-09-25 11:44:57 +05:30
6ba3d7d8db token expire time 1 min for testing 2023-09-25 11:44:04 +05:30
db119b2273 Merge pull request #337 from KiwiTechLLC/dev
Dev
2023-09-23 17:14:00 +05:30
651405ddef Merge pull request #336 from KiwiTechLLC/ZBKBCK-52
feedback changes and added mark all read
2023-09-22 23:29:38 +05:30
c484669a2d Merge pull request #335 from KiwiTechLLC/ZBKBCK-52
fixed guardian reject issue, updated ids in notification method, remo…
2023-09-13 18:18:07 +05:30
53f522ae41 Merge pull request #333 from KiwiTechLLC/dev
Dev
2023-09-13 16:09:10 +05:30
a3c2b68a0d Merge pull request #332 from KiwiTechLLC/ZBKBCK-52
fixed article reward points notification for 0 points earned
2023-09-13 14:50:24 +05:30
af25dc4e82 Merge pull request #331 from KiwiTechLLC/ZBKBCK-52
modified get article card current page method
2023-09-13 14:05:55 +05:30
71bbef84aa Merge pull request #330 from KiwiTechLLC/ZBKBCK-52
modified get article card current page method
2023-09-13 13:40:10 +05:30
52a40c085f Merge pull request #325 from KiwiTechLLC/dev
Dev
2023-09-11 17:54:18 +05:30
78fe41ae44 Merge pull request #321 from KiwiTechLLC/dev
Dev
2023-09-11 12:43:14 +05:30
1d44c642df Merge pull request #318 from KiwiTechLLC/dev
Dev
2023-09-08 17:56:57 +05:30
53c5b7079e Merge pull request #312 from KiwiTechLLC/dev
Dev
2023-09-07 15:29:44 +05:30
3ef9053290 Merge pull request #309 from KiwiTechLLC/dev
Dev
2023-09-06 18:10:45 +05:30
fdfe6e7dad Merge pull request #306 from KiwiTechLLC/dev
Dev
2023-09-06 12:33:22 +05:30
dd0a0cd2fa Merge pull request #296 from KiwiTechLLC/dev
Dev
2023-08-29 21:37:12 +05:30
674493e1ad Merge pull request #293 from KiwiTechLLC/dev
Dev
2023-08-29 20:00:01 +05:30
7cf3481ec6 Merge branch 'stage' into qa 2023-08-29 12:40:43 +05:30
de4b230cd1 Merge pull request #288 from KiwiTechLLC/dev
Dev
2023-08-29 12:11:06 +05:30
ad53e0086c Merge pull request #286 from KiwiTechLLC/dev
Dev
2023-08-28 20:35:49 +05:30
acd3592b2d Merge pull request #280 from KiwiTechLLC/dev
Dev
2023-08-28 12:55:32 +05:30
c2c9210a9a some changes 2023-08-28 11:54:38 +05:30
e3feab22a2 some changes 2023-08-28 11:51:12 +05:30
58b569225a Merge pull request #274 from KiwiTechLLC/dev
Dev
2023-08-25 21:00:25 +05:30
91471f69bd Merge pull request #272 from KiwiTechLLC/dev
Dev
2023-08-25 18:33:50 +05:30
1333c64d4f Merge pull request #269 from KiwiTechLLC/dev
Dev
2023-08-25 12:58:52 +05:30
56631ac633 Merge pull request #267 from KiwiTechLLC/dev
Dev
2023-08-25 12:53:12 +05:30
10efc952b7 Merge pull request #264 from KiwiTechLLC/dev
Dev
2023-08-24 19:19:05 +05:30
924eaab24b Merge pull request #259 from KiwiTechLLC/dev
Dev
2023-08-24 14:59:40 +05:30
c41dee333c Merge pull request #251 from KiwiTechLLC/dev
Dev
2023-08-23 12:57:22 +05:30
72c6a122fb Merge pull request #244 from KiwiTechLLC/dev
Dev
2023-08-22 16:19:10 +05:30
df30474fac Merge pull request #242 from KiwiTechLLC/dev
Dev
2023-08-22 13:51:09 +05:30
7c1725206b Merge pull request #238 from KiwiTechLLC/dev
Dev
2023-08-21 19:24:51 +05:30
987d60ef01 Merge pull request #235 from KiwiTechLLC/dev
Dev
2023-08-21 16:57:59 +05:30
1040d763ad Merge pull request #231 from KiwiTechLLC/dev
Dev
2023-08-21 12:58:09 +05:30
f04b4aeaad Merge pull request #216 from KiwiTechLLC/stage-hotFix
user notification issue
2023-08-16 16:43:16 +05:30
c7c55f2a04 user notification issue 2023-08-16 16:41:08 +05:30
bcf308b6eb Merge pull request #213 from KiwiTechLLC/qa
Qa
2023-08-16 11:39:02 +05:30
54748a6704 Merge pull request #210 from KiwiTechLLC/qa
Qa
2023-08-14 18:24:10 +05:30
74e704570a Merge pull request #208 from KiwiTechLLC/qa
Qa
2023-08-14 17:34:25 +05:30
136d0b732a Merge pull request #204 from KiwiTechLLC/qa
Qa
2023-08-14 11:46:35 +05:30
b974cc2010 Merge pull request #201 from KiwiTechLLC/qa
Qa
2023-08-11 17:08:10 +05:30
4fddc7b3e2 Merge pull request #131 from KiwiTechLLC/qa
Qa
2023-07-28 20:19:40 +05:30
ed18758cc5 Merge pull request #125 from KiwiTechLLC/qa
Qa
2023-07-28 11:13:10 +05:30
fb74c6c207 Merge pull request #67 from KiwiTechLLC/qa
change access token duration
2023-07-14 12:46:38 +05:30
87cb49d34d Merge pull request #66 from KiwiTechLLC/qa
Qa
2023-07-13 19:25:57 +05:30
4261b5ad29 Merge pull request #31 from KiwiTechLLC/qa
Qa
2023-06-30 17:22:54 +05:30
6c0c3e0aca Merge pull request #29 from KiwiTechLLC/qa
Qa
2023-06-30 16:26:16 +05:30
c6b220d6f2 Merge pull request #27 from KiwiTechLLC/qa
Qa
2023-06-30 15:54:15 +05:30
b5b793dc88 Merge pull request #25 from KiwiTechLLC/qa
Qa
2023-06-30 11:19:12 +05:30
1b5019e347 Merge pull request #22 from KiwiTechLLC/qa
Qa
2023-06-29 21:49:47 +05:30
8c1e96a3df Merge pull request #19 from KiwiTechLLC/qa
Qa
2023-06-29 21:25:52 +05:30
545fa8229b Merge pull request #12 from KiwiTechLLC/qa
Qa to stage First commit
2023-06-28 17:53:09 +05:30
18 changed files with 290 additions and 43 deletions

View File

@ -216,6 +216,7 @@ class GuardianSerializer(serializers.ModelSerializer):
last_name = serializers.SerializerMethodField('get_last_name')
auth_token = serializers.SerializerMethodField('get_auth_token')
refresh_token = serializers.SerializerMethodField('get_refresh_token')
sign_up = serializers.SerializerMethodField()
def get_auth_token(self, obj):
refresh = RefreshToken.for_user(obj.user)
@ -253,12 +254,16 @@ class GuardianSerializer(serializers.ModelSerializer):
"""user last name"""
return obj.user.last_name
def get_sign_up(self, obj):
return True if self.context.get('sign_up', '') else False
class Meta(object):
"""Meta info"""
model = Guardian
fields = ['id', 'auth_token', 'refresh_token', 'email', 'first_name', 'last_name', 'country_code',
'phone', 'family_name', 'gender', 'dob', 'referral_code', 'is_active', 'is_deleted',
'is_complete_profile', 'passcode', 'image', 'created_at', 'updated_at', 'user_type', 'country_name']
'is_complete_profile', 'passcode', 'image', 'created_at', 'updated_at', 'user_type',
'country_name', 'sign_up']
class JuniorSerializer(serializers.ModelSerializer):
@ -269,6 +274,7 @@ class JuniorSerializer(serializers.ModelSerializer):
last_name = serializers.SerializerMethodField('get_last_name')
auth_token = serializers.SerializerMethodField('get_auth_token')
refresh_token = serializers.SerializerMethodField('get_refresh_token')
sign_up = serializers.SerializerMethodField()
def get_auth_token(self, obj):
refresh = RefreshToken.for_user(obj.auth)
@ -295,13 +301,16 @@ class JuniorSerializer(serializers.ModelSerializer):
def get_last_name(self, obj):
return obj.auth.last_name
def get_sign_up(self, obj):
return True if self.context.get('sign_up', '') else False
class Meta(object):
"""Meta info"""
model = Junior
fields = ['id', 'auth_token', 'refresh_token', 'email', 'first_name', 'last_name', 'country_code',
'phone', 'gender', 'dob', 'guardian_code', 'referral_code','is_active', 'is_password_set',
'is_complete_profile', 'created_at', 'image', 'updated_at', 'user_type', 'country_name','is_invited',
'is_deleted']
'is_deleted', 'sign_up']
class EmailVerificationSerializer(serializers.ModelSerializer):
"""Email verification serializer"""
@ -373,17 +382,16 @@ class UpdateUserNotificationSerializer(serializers.ModelSerializer):
fields = ['push_notification', 'email_notification', 'sms_notification']
def create(self, validated_data):
instance = UserNotification.objects.filter(user=self.context).last()
if instance:
# change notification status
instance.push_notification = validated_data.get('push_notification',instance.push_notification)
instance.email_notification = validated_data.get('email_notification', instance.email_notification)
instance.sms_notification = validated_data.get('sms_notification', instance.sms_notification)
instance.save()
else:
instance = UserNotification.objects.create(user=self.context)
instance, _ = UserNotification.objects.update_or_create(
user=self.context,
defaults={
'push_notification': validated_data.get('push_notification'),
'email_notification': validated_data.get('email_notification'),
'sms_notification': validated_data.get('sms_notification', False),
})
return instance
class UserPhoneOtpSerializer(serializers.ModelSerializer):
"""User Phone serializers"""
class Meta(object):

View File

@ -0,0 +1,22 @@
{% extends "templated_email/email_base.email" %}
{% block subject %}
Account Activated
{% endblock %}
{% block plain %}
<tr>
<td style="padding: 0 27px 15px;">
<p style="margin: 0; font-size: 16px; line-height: 20px; padding: 36px 0 0; font-weight: 500; color: #1f2532;">
Hi User,
</p>
</td>
</tr>
<tr>
<td style="padding: 0 27px 22px;">
<p style="margin: 0;font-size: 14px; font-weight: 400; line-height: 21px; color: #1f2532;">
We're pleased to inform you that your account has been successfully reactivated by our admin team. Welcome back to ZOD ! <br><br> You can now access all the features and services as before. If you have any questions or need assistance, please feel free to reach out to our support team. <br><br> Thank you for being a valued member of our community.
</p>
</td>
</tr>
{% endblock %}

View File

@ -74,7 +74,7 @@ class GoogleLoginMixin(object):
user_info = response.json()
email = user_info['email']
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']
except Exception as e:
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
@ -90,6 +90,11 @@ class GoogleLoginMixin(object):
ERROR_CODE["2071"],
response_status=status.HTTP_400_BAD_REQUEST
)
if not junior_query.is_active:
return custom_error_response(
ERROR_CODE["2075"],
response_status=status.HTTP_404_NOT_FOUND
)
serializer = JuniorSerializer(junior_query)
elif str(user_type) == '2':
guardian_query = Guardian.objects.filter(user=user_data.last()).last()
@ -98,12 +103,21 @@ class GoogleLoginMixin(object):
ERROR_CODE["2070"],
response_status=status.HTTP_400_BAD_REQUEST
)
if not guardian_query.is_active:
return custom_error_response(
ERROR_CODE["2075"],
response_status=status.HTTP_404_NOT_FOUND
)
serializer = GuardianSerializer(guardian_query)
else:
return custom_error_response(
ERROR_CODE["2069"],
response_status=status.HTTP_400_BAD_REQUEST
)
device_detail, created = UserDeviceDetails.objects.get_or_create(user=user_data.last())
if device_detail:
device_detail.device_id = device_id
device_detail.save()
return custom_response(SUCCESS_CODE['3003'], serializer.data,
response_status=status.HTTP_200_OK)
@ -115,7 +129,7 @@ class GoogleLoginMixin(object):
junior_code=generate_code(JUN, user_obj.id),
referral_code=generate_code(ZOD, user_obj.id)
)
serializer = JuniorSerializer(junior_query)
serializer = JuniorSerializer(junior_query, context={'sign_up': True})
position = Junior.objects.all().count()
JuniorPoints.objects.create(junior=junior_query, position=position)
elif str(user_type) == '2':
@ -124,7 +138,7 @@ class GoogleLoginMixin(object):
guardian_code=generate_code(GRD, user_obj.id),
referral_code=generate_code(ZOD, user_obj.id)
)
serializer = GuardianSerializer(guardian_query)
serializer = GuardianSerializer(guardian_query, context={'sign_up': True})
else:
user_obj.delete()
return custom_error_response(
@ -170,7 +184,7 @@ class SigninWithApple(views.APIView):
user_data = {"email": decoded_data.get('email'), "username": decoded_data.get('email'), "is_active": True}
if decoded_data.get("email"):
try:
user = User.objects.get(email=decoded_data.get("email"))
user = User.objects.get(email__iexact=decoded_data.get("email"))
if str(user_type) == '1':
junior_data = Junior.objects.filter(auth=user).last()
if not junior_data:
@ -192,6 +206,10 @@ class SigninWithApple(views.APIView):
ERROR_CODE["2069"],
response_status=status.HTTP_400_BAD_REQUEST
)
device_detail, created = UserDeviceDetails.objects.get_or_create(user=user)
if device_detail:
device_detail.device_id = device_id
device_detail.save()
return custom_response(SUCCESS_CODE['3003'], serializer.data,
response_status=status.HTTP_200_OK)
@ -202,7 +220,7 @@ class SigninWithApple(views.APIView):
signup_method='3',
junior_code=generate_code(JUN, user.id),
referral_code=generate_code(ZOD, user.id))
serializer = JuniorSerializer(junior_query)
serializer = JuniorSerializer(junior_query, context={'sign_up': True})
position = Junior.objects.all().count()
JuniorPoints.objects.create(junior=junior_query, position=position)
elif str(user_type) == '2':
@ -210,7 +228,7 @@ class SigninWithApple(views.APIView):
signup_method='3',
guardian_code=generate_code(GRD, user.id),
referral_code=generate_code(ZOD, user.id))
serializer = GuardianSerializer(guardian_query)
serializer = GuardianSerializer(guardian_query, context={'sign_up': True})
else:
user.delete()
return custom_error_response(
@ -742,7 +760,7 @@ class ForceUpdateViewSet(GenericViewSet, mixins.CreateModelMixin):
:param kwargs:
: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)
obj_data = [ForceUpdate(**item) for item in request.data]
try:

View File

@ -96,8 +96,8 @@ ERROR_CODE = {
"2067": "Action not allowed. User type missing.",
"2068": "No guardian associated with this junior",
"2069": "Invalid user type",
"2070": "You do not find as a guardian",
"2071": "You do not find as a junior",
"2070": "You are not registered as a guardian in our system. Please try again as 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",
"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",

View File

@ -13,7 +13,7 @@ from django.db.models import F, Window
from django.db.models.functions.window import Rank
# local imports
from base.constants import PENDING, IN_PROGRESS, JUNIOR
from base.constants import PENDING, IN_PROGRESS, JUNIOR, GUARDIAN
from guardian.models import JuniorTask
from junior.models import JuniorPoints
from notifications.constants import PENDING_TASK_EXPIRING, IN_PROGRESS_TASK_EXPIRING, NOTIFICATION_DICT, TOP_JUNIOR
@ -48,12 +48,13 @@ def notify_task_expiry():
:return:
"""
all_pending_tasks = JuniorTask.objects.filter(
junior__is_verified=True,
task_status__in=[PENDING, IN_PROGRESS],
due_date__range=[datetime.datetime.now().date(),
(datetime.datetime.now().date() + datetime.timedelta(days=1))])
if pending_tasks := all_pending_tasks.filter(task_status=PENDING):
for task in pending_tasks:
send_notification(PENDING_TASK_EXPIRING, None, None, task.junior.auth_id,
send_notification(PENDING_TASK_EXPIRING, task.guardian.user_id, GUARDIAN, task.junior.auth_id,
{'task_id': task.id})
if in_progress_tasks := all_pending_tasks.filter(task_status=IN_PROGRESS):
for task in in_progress_tasks:

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

@ -11,7 +11,7 @@ import tempfile
# Import date time module's function
from datetime import datetime, time
# import Number constant
from base.constants import NUMBER
from base.constants import NUMBER, GUARDIAN
# Import Junior's model
from junior.models import Junior, JuniorPoints
# Import guardian's model
@ -117,7 +117,7 @@ def update_referral_points(referral_code, referral_code_used):
junior_query.total_points = junior_query.total_points + NUMBER['five']
junior_query.referral_points = junior_query.referral_points + NUMBER['five']
junior_query.save()
send_notification.delay(REFERRAL_POINTS, None, None, junior_queryset.auth_id, {})
send_notification.delay(REFERRAL_POINTS, None, GUARDIAN, junior_queryset.auth_id, {})

View File

@ -16,7 +16,7 @@ from junior.models import Junior, JuniorPoints, JuniorGuardianRelationship, Juni
from guardian.tasks import generate_otp
from base.messages import ERROR_CODE, SUCCESS_CODE
from base.constants import (PENDING, IN_PROGRESS, REJECTED, REQUESTED, COMPLETED, NUMBER, JUN, ZOD, EXPIRED,
GUARDIAN_CODE_STATUS, JUNIOR)
GUARDIAN_CODE_STATUS, JUNIOR, GUARDIAN)
from guardian.models import Guardian, JuniorTask
from account.models import UserEmailOtp, UserNotification
from junior.utils import junior_notification_email, junior_approval_mail, get_junior_leaderboard_rank
@ -323,7 +323,7 @@ class AddJuniorSerializer(serializers.ModelSerializer):
"""Notification email"""
junior_notification_email.delay(email, full_name, email, special_password)
# push notification
send_notification.delay(ASSOCIATE_JUNIOR, None, None, junior_data.auth_id, {})
send_notification.delay(ASSOCIATE_JUNIOR, None, GUARDIAN, junior_data.auth_id, {})
return junior_data

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,
@ -362,7 +363,7 @@ class RemoveJuniorAPIView(views.APIView):
# save serializer
serializer.save()
JuniorGuardianRelationship.objects.filter(guardian=guardian, junior=junior_queryset).delete()
send_notification.delay(REMOVE_JUNIOR, None, None, junior_queryset.auth_id, {})
send_notification.delay(REMOVE_JUNIOR, None, GUARDIAN, junior_queryset.auth_id, {})
return custom_response(SUCCESS_CODE['3022'], serializer.data, response_status=status.HTTP_200_OK)
return custom_error_response(serializer.errors, response_status=status.HTTP_400_BAD_REQUEST)
else:
@ -712,7 +713,7 @@ class CompleteArticleAPIView(views.APIView):
total_earn_points=Sum('earn_points'))['total_earn_points']
data = {"total_earn_points":total_earn_points}
if total_earn_points:
send_notification.delay(ARTICLE_REWARD_POINTS, None, None,
send_notification.delay(ARTICLE_REWARD_POINTS, None, GUARDIAN,
request.user.id, {'points': total_earn_points})
return custom_response(SUCCESS_CODE['3042'], data, response_status=status.HTTP_200_OK)
except Exception as e:
@ -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)

View File

@ -11,3 +11,4 @@ class NotificationAdmin(admin.ModelAdmin):
"""Notification Admin"""
list_display = ['id', 'notification_type', 'notification_to', 'data', 'is_read']
list_filter = ['notification_type']
search_fields = ['notification_to']

View File

@ -22,79 +22,93 @@ ARTICLE_REWARD_POINTS = 17
REMOVE_JUNIOR = 18
TEST_NOTIFICATION = 99
# notification dictionary
NOTIFICATION_DICT = {
REGISTRATION: {
"notification_type": REGISTRATION,
"title": "Successfully registered!",
"body": "You have registered successfully. Now login and complete your profile."
},
# user will receive notification as soon junior
# sign up application using their guardian code for association
ASSOCIATE_REQUEST: {
"notification_type": ASSOCIATE_REQUEST,
"title": "Associate request!",
"body": "You have request from {from_user} to associate with you."
},
# Juniors will receive notification when
# custodians reject their request for associate
ASSOCIATE_REJECTED: {
"notification_type": ASSOCIATE_REJECTED,
"title": "Associate request rejected!",
"body": "Your request to associate has been rejected by {from_user}."
},
# Juniors will receive notification when
# custodians approve their request for associate
ASSOCIATE_APPROVED: {
"notification_type": ASSOCIATE_APPROVED,
"title": "Associate request approved!",
"body": "Your request to associate has been approved by {from_user}."
},
# Juniors will receive Notifications
# for every Points earned by referrals
REFERRAL_POINTS: {
"notification_type": REFERRAL_POINTS,
"title": "Earn Referral points!",
"body": "You earn 5 points for referral."
},
# Juniors will receive notification
# once any custodians add them in their account
ASSOCIATE_JUNIOR: {
"notification_type": ASSOCIATE_JUNIOR,
"title": "Profile already setup!",
"body": "Your guardian has already setup your profile."
},
ASSOCIATE_EXISTING_JUNIOR: {
"notification_type": ASSOCIATE_EXISTING_JUNIOR,
"title": "Associated to guardian",
"body": "Your are associated to your guardian {from_user}."
},
# Juniors will receive Notification
# for every Task Assign by Custodians
TASK_ASSIGNED: {
"notification_type": TASK_ASSIGNED,
"title": "New task assigned!",
"body": "{from_user} has assigned you a new task."
},
# Guardian will receive notification as soon
# as junior send task for approval
TASK_ACTION: {
"notification_type": TASK_ACTION,
"title": "Task completion approval!",
"body": "{from_user} completed their task {task_name}."
},
# Juniors will receive notification as soon
# as their task is rejected by custodians
TASK_REJECTED: {
"notification_type": TASK_REJECTED,
"title": "Task completion rejected!",
"body": "Your task completion request has been rejected by {from_user}."
},
# Juniors will receive notification as soon as their task is approved by custodians
# and for every Points earned by Task completion
TASK_APPROVED: {
"notification_type": TASK_APPROVED,
"title": "Task completion approved!",
"body": "Your task completion request has been approved by {from_user}. "
"Also you earned 5 points for successful completion."
},
# Juniors will receive notification when their task end date about to end
PENDING_TASK_EXPIRING: {
"notification_type": PENDING_TASK_EXPIRING,
"title": "Task expiring soon!",
"body": "Your task {task_name} is expiring soon. Please complete it."
},
# User will receive notification when their assigned task is about to end
# and juniors have not performed any action
IN_PROGRESS_TASK_EXPIRING: {
"notification_type": IN_PROGRESS_TASK_EXPIRING,
"title": "Task expiring soon!",
"body": "{from_user} didn't take any action on assigned task {task_name} and it's expiring soon. "
"Please assist to complete it."
@ -102,27 +116,32 @@ NOTIFICATION_DICT = {
# Juniors will receive Notification
# related to Leaderboard progress
TOP_JUNIOR: {
"notification_type": TOP_JUNIOR,
"title": "Leaderboard topper!",
"body": "{from_user} is on top in leaderboard with {points} points."
},
# Juniors will receive notification
# when admin add any new financial learnings
NEW_ARTICLE_PUBLISHED: {
"notification_type": NEW_ARTICLE_PUBLISHED,
"title": "Time to read!",
"body": "A new article has been published."
},
# Juniors will receive notification when they earn points by reading financial Learning
ARTICLE_REWARD_POINTS: {
"notification_type": ARTICLE_REWARD_POINTS,
"title": "Article reward points!",
"body": "You are rewarded with {points} points for reading article and answering questions. "
},
# Juniors will receive notification as soon as their custodians remove them from account
REMOVE_JUNIOR: {
"notification_type": REMOVE_JUNIOR,
"title": "Disassociate by guardian!",
"body": "Your guardian has disassociated you."
},
# Test notification
TEST_NOTIFICATION: {
"notification_type": TEST_NOTIFICATION,
"title": "Test Notification",
"body": "This notification is for testing purpose from {from_user}."
}

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.2 on 2023-09-29 07:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('notifications', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='notification',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
]

View File

@ -18,6 +18,7 @@ class Notification(models.Model):
data = models.JSONField(default=dict, blank=True, null=True)
is_read = models.BooleanField(default=False)
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
""" string representation """

View File

@ -36,7 +36,7 @@ class NotificationListSerializer(serializers.ModelSerializer):
class Meta(object):
"""meta info"""
model = Notification
fields = ['id', 'data', 'badge', 'is_read', 'created_at']
fields = ['id', 'notification_type', 'data', 'badge', 'is_read', 'updated_at']
@staticmethod
def get_badge(obj):

View File

@ -24,6 +24,7 @@ User = get_user_model()
def register_fcm_token(user_id, registration_id, device_id, device_type):
""" used to register the fcm device token"""
FCMDevice.objects.filter(registration_id=registration_id).delete()
device, _ = FCMDevice.objects.update_or_create(user_id=user_id,
defaults={'device_id': device_id, 'type': device_type,
'active': True,
@ -88,9 +89,14 @@ def get_notification_data(notification_type, from_user_id, from_user_type, to_us
push_data['body'] = push_data['body'].format(from_user=from_user_name, task_name=task_name, points=points)
notification_data['body'] = notification_data['body'].format(from_user=from_user_name,
task_name=task_name, points=points)
push_data['to_user_type'] = GUARDIAN if from_user_type == JUNIOR else JUNIOR
notification_data['to_user_type'] = GUARDIAN if from_user_type == JUNIOR else JUNIOR
notification_data['from_user'] = from_user_name
notification_data['from_user_image'] = from_user_image
notification_data.update(extra_data)
to_user = User.objects.filter(id=to_user_id).first()
return notification_data, push_data, from_user, to_user
@ -104,14 +110,25 @@ def send_notification(notification_type, from_user_id, from_user_type, to_user_i
notification_data, push_data, from_user, to_user = get_notification_data(notification_type, from_user_id,
from_user_type, to_user_id, extra_data)
user_notification_type = UserNotification.objects.filter(user=to_user).first()
Notification.objects.create(notification_type=notification_type, notification_from=from_user,
notification_to=to_user, data=notification_data)
# notification create method changed on 28sep as per changes required
task_id = extra_data['task_id'] if 'task_id' in extra_data else None
Notification.objects.update_or_create(data__has_key='task_id', data__task_id=task_id,
notification_from=from_user, notification_to=to_user,
defaults={
'notification_type': notification_type,
'notification_from': from_user,
'notification_to': to_user,
'data': notification_data
})
if user_notification_type and user_notification_type.push_notification:
send_push(to_user, push_data)
def send_push(user, data):
""" used to send push notification to specific user """
data['notification_type'] = str(data['notification_type'])
user.fcmdevice_set.filter(active=True).send_message(
Message(notification=FirebaseNotification(data['title'], data['body']), data=data)
)
@ -119,6 +136,7 @@ def send_push(user, data):
def send_multiple_push(queryset, data):
""" used to send same notification to multiple users """
data['notification_type'] = str(data['notification_type'])
FCMDevice.objects.filter(user__in=queryset, active=True).send_message(
Message(notification=FirebaseNotification(data['title'], data['body']), data=data)
)

View File

@ -33,7 +33,7 @@ class NotificationViewSet(viewsets.GenericViewSet):
:return:
"""
queryset = Notification.objects.filter(notification_to_id=request.auth.payload['user_id']
).select_related('notification_to').order_by('-id')
).select_related('notification_to').order_by('-updated_at', '-id')
paginator = CustomPageNumberPagination()
paginated_queryset = paginator.paginate_queryset(queryset, request)
serializer = self.serializer_class(paginated_queryset, many=True)
@ -58,8 +58,12 @@ class NotificationViewSet(viewsets.GenericViewSet):
"""
notify_task_expiry()
notify_top_junior()
send_notification(TEST_NOTIFICATION, None, None, request.auth.payload['user_id'],
notification_type = request.query_params.get('type', TEST_NOTIFICATION)
from_user_type = request.query_params.get('from_user_type')
send_notification(int(notification_type), None, from_user_type, request.auth.payload['user_id'],
{})
if notification_type and request.query_params.get('clear_all'):
Notification.objects.filter(notification_type=notification_type).delete()
return custom_response(SUCCESS_CODE["3000"])
@action(methods=['patch'], url_path='mark-as-read', url_name='mark-as-read', detail=False,
@ -68,8 +72,14 @@ class NotificationViewSet(viewsets.GenericViewSet):
"""
notification list
"""
if request.query_params.get('all'):
Notification.objects.filter(notification_to_id=request.auth.payload['user_id']).update(is_read=True)
elif request.data.get('id'):
if request.data.get('id'):
Notification.objects.filter(id__in=request.data.get('id')).update(is_read=True)
elif request.query_params.get('mark_all'):
Notification.objects.filter(notification_to_id=request.auth.payload['user_id']).update(is_read=True)
elif request.query_params.get('clear_all'):
Notification.objects.filter(notification_to_id=request.auth.payload['user_id']).delete()
return custom_response(SUCCESS_CODE['3039'], response_status=status.HTTP_200_OK)

View File

@ -120,17 +120,23 @@ class UserManagementViewSet(GenericViewSet, mixins.ListModelMixin,
if user_type not in [GUARDIAN, JUNIOR]:
return custom_error_response(ERROR_CODE['2067'], status.HTTP_400_BAD_REQUEST)
email_template = 'user_deactivate.email'
if user_type == GUARDIAN:
obj = Guardian.objects.filter(user_id=kwargs['pk'], is_verified=True).select_related('user').first()
elif user_type == JUNIOR:
obj = Junior.objects.filter(auth_id=kwargs['pk'], is_verified=True).select_related('auth').first()
if not obj:
return custom_error_response(ERROR_CODE['2004'], status.HTTP_400_BAD_REQUEST)
if obj.is_active:
deactivate_email_template = 'user_deactivate.email'
obj.is_active = False
send_email([obj.user.email if user_type == GUARDIAN else obj.auth.email], email_template)
send_email([obj.user.email if user_type == GUARDIAN else obj.auth.email],
deactivate_email_template)
else:
activate_email_template = 'user_activate.email'
obj.is_active = True
send_email([obj.user.email if user_type == GUARDIAN else obj.auth.email],
activate_email_template)
obj.save()
return custom_response(SUCCESS_CODE['3038'])

View File

@ -56,7 +56,14 @@ if ENV in ['dev', 'qa', 'stage']:
# Add more trusted origins as needed
]
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
ALLOWED_HOSTS = ['*']
@ -138,9 +145,10 @@ REST_FRAMEWORK = {
# define jwt token
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(hours=2, 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
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
@ -200,7 +208,7 @@ AUTH_PASSWORD_VALIDATORS = [
# database query logs settings
# Allows us to check db hits
# useful to optimize db query and hit
LOGGING = {
LOGGING1 = {
"version": 1,
"filters": {
"require_debug_true": {