mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 10:26:16 +00:00
notification changes
This commit is contained in:
@ -22,7 +22,7 @@ from account.models import UserEmailOtp, UserNotification
|
||||
from junior.utils import junior_notification_email, junior_approval_mail
|
||||
from guardian.utils import real_time, update_referral_points, convert_timedelta_into_datetime
|
||||
from notifications.utils import send_notification, send_notification_to_junior, send_notification_to_guardian
|
||||
from notifications.constants import (INVITED_GUARDIAN, APPROVED_JUNIOR, SKIPPED_PROFILE_SETUP, TASK_ACTION,
|
||||
from notifications.constants import (INVITATION, ASSOCIATE_REQUEST, SKIPPED_PROFILE_SETUP, TASK_ACTION,
|
||||
TASK_SUBMITTED)
|
||||
from web_admin.models import ArticleCard
|
||||
|
||||
@ -451,8 +451,8 @@ class AddGuardianSerializer(serializers.ModelSerializer):
|
||||
"""Notification email"""
|
||||
junior_notification_email(email, full_name, email, password)
|
||||
junior_approval_mail(email, full_name)
|
||||
send_notification_to_junior.delay(INVITED_GUARDIAN, guardian_data.user.id, junior_data.auth.id, {})
|
||||
send_notification_to_guardian.delay(APPROVED_JUNIOR, junior_data.auth.id, guardian_data.user.id, {})
|
||||
send_notification_to_junior.delay(INVITATION, guardian_data.user.id, junior_data.auth.id, {})
|
||||
send_notification_to_guardian.delay(ASSOCIATE_REQUEST, junior_data.auth.id, guardian_data.user.id, {})
|
||||
return guardian_data
|
||||
|
||||
class StartTaskSerializer(serializers.ModelSerializer):
|
||||
|
@ -10,3 +10,5 @@ from notifications.models import Notification
|
||||
class NotificationAdmin(admin.ModelAdmin):
|
||||
"""Notification Admin"""
|
||||
list_display = ['id', 'notification_type', 'notification_to', 'data', 'is_read']
|
||||
list_filter = ['notification_type']
|
||||
|
@ -1,19 +1,22 @@
|
||||
"""
|
||||
notification constants file
|
||||
"""
|
||||
from base.constants import NUMBER
|
||||
REGISTRATION = NUMBER['one']
|
||||
TASK_ASSIGNED = NUMBER['two']
|
||||
INVITED_GUARDIAN = NUMBER['three']
|
||||
APPROVED_JUNIOR = NUMBER['four']
|
||||
REFERRAL_POINTS = NUMBER['five']
|
||||
TASK_POINTS = NUMBER['six']
|
||||
TASK_REJECTED = NUMBER['seven']
|
||||
SKIPPED_PROFILE_SETUP = NUMBER['eight']
|
||||
TASK_SUBMITTED = NUMBER['nine']
|
||||
TASK_ACTION = NUMBER['ten']
|
||||
LEADERBOARD_RANKING = NUMBER['eleven']
|
||||
REMOVE_JUNIOR = NUMBER['twelve']
|
||||
REGISTRATION = 1
|
||||
INVITATION = 2
|
||||
ASSOCIATE_REQUEST = 3
|
||||
REFERRAL_POINTS = 4
|
||||
SKIPPED_PROFILE_SETUP = 5
|
||||
|
||||
TASK_ASSIGNED = 6
|
||||
TASK_SUBMITTED = 7
|
||||
TASK_ACTION = 8
|
||||
TASK_REJECTED = 9
|
||||
TASK_APPROVED = 10
|
||||
TASK_POINTS = 11
|
||||
|
||||
LEADERBOARD_RANKING = 12
|
||||
REMOVE_JUNIOR = 13
|
||||
|
||||
TEST_NOTIFICATION = 99
|
||||
|
||||
NOTIFICATION_DICT = {
|
||||
@ -21,41 +24,46 @@ NOTIFICATION_DICT = {
|
||||
"title": "Successfully registered!",
|
||||
"body": "You have registered successfully. Now login and complete your profile."
|
||||
},
|
||||
TASK_ASSIGNED: {
|
||||
"title": "New task assigned !!",
|
||||
"body": "{from_user} has assigned you a new task."
|
||||
INVITATION: {
|
||||
"title": "Invitation sent!",
|
||||
"body": "Invitation has been successfully sent."
|
||||
},
|
||||
INVITED_GUARDIAN: {
|
||||
"title": "Invite guardian",
|
||||
"body": "Invite guardian successfully"
|
||||
},
|
||||
APPROVED_JUNIOR: {
|
||||
"title": "Approve junior !",
|
||||
ASSOCIATE_REQUEST: {
|
||||
"title": "Associate request!",
|
||||
"body": "You have request from {from_user} to associate with you."
|
||||
},
|
||||
REFERRAL_POINTS: {
|
||||
"title": "Earn Referral points",
|
||||
"title": "Earn Referral points!",
|
||||
"body": "You earn 5 points for referral."
|
||||
},
|
||||
TASK_POINTS: {
|
||||
"title": "Earn Task points!",
|
||||
"body": "You earn 5 points for task."
|
||||
},
|
||||
TASK_REJECTED: {
|
||||
"title": "Task rejected!",
|
||||
"body": "Your task has been rejected."
|
||||
},
|
||||
# notification once any custodian adds junior in their account
|
||||
SKIPPED_PROFILE_SETUP: {
|
||||
"title": "Skipped profile setup!",
|
||||
"body": "Your guardian {from_user} has setup your profile."
|
||||
"title": "Profile already setup!",
|
||||
"body": "Your guardian has already setup your profile."
|
||||
},
|
||||
TASK_ASSIGNED: {
|
||||
"title": "New task assigned!",
|
||||
"body": "{from_user} has assigned you a new task."
|
||||
},
|
||||
TASK_SUBMITTED: {
|
||||
"title": "Task submitted!",
|
||||
"body": "Your task has been submitted successfully."
|
||||
"body": "Your task has been submitted for approval."
|
||||
},
|
||||
TASK_ACTION: {
|
||||
"title": "Task completion approval!",
|
||||
"body": "You have request from {from_user} for task approval."
|
||||
"body": "You have request from {from_user} for task completion."
|
||||
},
|
||||
TASK_REJECTED: {
|
||||
"title": "Task completion rejected!",
|
||||
"body": "Your task completion request has been rejected by {from_user}."
|
||||
},
|
||||
TASK_APPROVED: {
|
||||
"title": "Task completion approved!",
|
||||
"body": "Your task completion request has been approved by {from_user}."
|
||||
},
|
||||
TASK_POINTS: {
|
||||
"title": "Earned Task points!",
|
||||
"body": "You earn 5 points for task."
|
||||
},
|
||||
LEADERBOARD_RANKING: {
|
||||
"title": "Leader board rank!",
|
||||
@ -63,7 +71,7 @@ NOTIFICATION_DICT = {
|
||||
},
|
||||
REMOVE_JUNIOR: {
|
||||
"title": "Disassociate by guardian!",
|
||||
"body": "Your guardian disassociate you ."
|
||||
"body": "Your guardian has disassociated you."
|
||||
},
|
||||
TEST_NOTIFICATION: {
|
||||
"title": "Test Notification",
|
||||
|
@ -97,6 +97,13 @@ def send_push(user, data):
|
||||
|
||||
@shared_task()
|
||||
def send_notification_to_guardian(notification_type, from_user_id, to_user_id, extra_data):
|
||||
"""
|
||||
:param notification_type:
|
||||
:param from_user_id:
|
||||
:param to_user_id:
|
||||
:param extra_data:
|
||||
:return:
|
||||
"""
|
||||
from_user = None
|
||||
if from_user_id:
|
||||
from_user = Junior.objects.filter(auth_id=from_user_id).select_related('auth').first()
|
||||
@ -109,6 +116,13 @@ def send_notification_to_guardian(notification_type, from_user_id, to_user_id, e
|
||||
|
||||
@shared_task()
|
||||
def send_notification_to_junior(notification_type, from_user_id, to_user_id, extra_data):
|
||||
"""
|
||||
:param notification_type:
|
||||
:param from_user_id:
|
||||
:param to_user_id:
|
||||
:param extra_data:
|
||||
:return:
|
||||
"""
|
||||
from_user = None
|
||||
if from_user_id:
|
||||
from_user = Guardian.objects.filter(user_id=from_user_id).select_related('user').first()
|
||||
|
Reference in New Issue
Block a user