mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 10:05:21 +00:00
Merge branch 'dev' into ZBKADM-67
This commit is contained in:
@ -87,6 +87,8 @@ ERROR_CODE = {
|
|||||||
# task status
|
# task status
|
||||||
"2060": "Task does not exist or not in pending state",
|
"2060": "Task does not exist or not in pending state",
|
||||||
"2061": "Please insert image or check the image is valid or not.",
|
"2061": "Please insert image or check the image is valid or not.",
|
||||||
|
# email not null
|
||||||
|
"2062": "Please enter email address"
|
||||||
}
|
}
|
||||||
"""Success message code"""
|
"""Success message code"""
|
||||||
SUCCESS_CODE = {
|
SUCCESS_CODE = {
|
||||||
|
Binary file not shown.
@ -25,7 +25,10 @@ from base.messages import ERROR_CODE, SUCCESS_CODE
|
|||||||
from base.constants import NUMBER, JUN, ZOD, GRD
|
from base.constants import NUMBER, JUN, ZOD, GRD
|
||||||
from junior.models import Junior, JuniorPoints
|
from junior.models import Junior, JuniorPoints
|
||||||
from .utils import real_time, convert_timedelta_into_datetime, update_referral_points
|
from .utils import real_time, convert_timedelta_into_datetime, update_referral_points
|
||||||
|
# notification's constant
|
||||||
|
from notifications.constants import TASK_POINTS, TASK_REJECTED
|
||||||
|
# send notification function
|
||||||
|
from notifications.utils import send_notification
|
||||||
|
|
||||||
|
|
||||||
# In this serializer file
|
# In this serializer file
|
||||||
@ -61,7 +64,7 @@ class UserSerializer(serializers.ModelSerializer):
|
|||||||
try:
|
try:
|
||||||
"""Create user profile"""
|
"""Create user profile"""
|
||||||
user = User.objects.create_user(username=email, email=email, password=password)
|
user = User.objects.create_user(username=email, email=email, password=password)
|
||||||
UserNotification.objects.create(user=user)
|
UserNotification.objects.get_or_create(user=user)
|
||||||
if user_type == str(NUMBER['one']):
|
if user_type == str(NUMBER['one']):
|
||||||
# create junior profile
|
# create junior profile
|
||||||
Junior.objects.create(auth=user, junior_code=generate_code(JUN, user.id),
|
Junior.objects.create(auth=user, junior_code=generate_code(JUN, user.id),
|
||||||
@ -328,27 +331,30 @@ class ApproveTaskSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
"""update task status """
|
"""update task status """
|
||||||
instance = self.context['task_instance']
|
with transaction.atomic():
|
||||||
junior = self.context['junior']
|
instance = self.context['task_instance']
|
||||||
junior_details = Junior.objects.filter(id=junior).last()
|
junior = self.context['junior']
|
||||||
junior_data, created = JuniorPoints.objects.get_or_create(junior=junior_details)
|
junior_details = Junior.objects.filter(id=junior).last()
|
||||||
if self.context['action'] == str(NUMBER['one']):
|
junior_data, created = JuniorPoints.objects.get_or_create(junior=junior_details)
|
||||||
# approve the task
|
if self.context['action'] == str(NUMBER['one']):
|
||||||
instance.task_status = str(NUMBER['five'])
|
# approve the task
|
||||||
instance.is_approved = True
|
instance.task_status = str(NUMBER['five'])
|
||||||
# update total task point
|
instance.is_approved = True
|
||||||
junior_data.total_points = junior_data.total_points + instance.points
|
# update total task point
|
||||||
# update complete time of task
|
junior_data.total_points = junior_data.total_points + instance.points
|
||||||
instance.completed_on = real_time()
|
# update complete time of task
|
||||||
else:
|
instance.completed_on = real_time()
|
||||||
# reject the task
|
send_notification.delay(TASK_POINTS, None, junior_details.auth.id, {})
|
||||||
instance.task_status = str(NUMBER['three'])
|
else:
|
||||||
instance.is_approved = False
|
# reject the task
|
||||||
# update total task point
|
instance.task_status = str(NUMBER['three'])
|
||||||
junior_data.total_points = junior_data.total_points - instance.points
|
instance.is_approved = False
|
||||||
# update reject time of task
|
# update total task point
|
||||||
instance.rejected_on = real_time()
|
junior_data.total_points = junior_data.total_points - instance.points
|
||||||
instance.save()
|
# update reject time of task
|
||||||
junior_data.save()
|
instance.rejected_on = real_time()
|
||||||
return instance
|
send_notification.delay(TASK_REJECTED, None, junior_details.auth.id, {})
|
||||||
|
instance.save()
|
||||||
|
junior_data.save()
|
||||||
|
return junior_details
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ from junior.models import Junior, JuniorPoints
|
|||||||
from .models import JuniorTask
|
from .models import JuniorTask
|
||||||
# Import app from celery
|
# Import app from celery
|
||||||
from zod_bank.celery import app
|
from zod_bank.celery import app
|
||||||
|
# notification's constant
|
||||||
|
from notifications.constants import REFERRAL_POINTS
|
||||||
|
# send notification function
|
||||||
|
from notifications.utils import send_notification
|
||||||
# Define upload image on
|
# Define upload image on
|
||||||
# ali baba cloud
|
# ali baba cloud
|
||||||
# firstly save image
|
# firstly save image
|
||||||
@ -85,6 +89,8 @@ def update_referral_points(referral_code, referral_code_used):
|
|||||||
junior_query.total_points = junior_query.total_points + NUMBER['five']
|
junior_query.total_points = junior_query.total_points + NUMBER['five']
|
||||||
junior_query.referral_points = junior_query.referral_points + NUMBER['five']
|
junior_query.referral_points = junior_query.referral_points + NUMBER['five']
|
||||||
junior_query.save()
|
junior_query.save()
|
||||||
|
send_notification.delay(REFERRAL_POINTS, None, junior_queryset.auth.id, {})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
|
@ -35,7 +35,7 @@ from account.utils import custom_response, custom_error_response, OTP_EXPIRY, se
|
|||||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||||
from base.constants import NUMBER
|
from base.constants import NUMBER
|
||||||
from .utils import upload_image_to_alibaba
|
from .utils import upload_image_to_alibaba
|
||||||
from notifications.constants import REGISTRATION, TASK_CREATED
|
from notifications.constants import REGISTRATION, TASK_CREATED, LEADERBOARD_RANKING
|
||||||
from notifications.utils import send_notification
|
from notifications.utils import send_notification
|
||||||
|
|
||||||
""" Define APIs """
|
""" Define APIs """
|
||||||
@ -245,6 +245,7 @@ class TopJuniorListAPIView(viewsets.ModelViewSet):
|
|||||||
# Update the position field for each JuniorPoints object
|
# Update the position field for each JuniorPoints object
|
||||||
for index, junior in enumerate(junior_total_points):
|
for index, junior in enumerate(junior_total_points):
|
||||||
junior.position = index + 1
|
junior.position = index + 1
|
||||||
|
send_notification.delay(LEADERBOARD_RANKING, None, junior.junior.auth.id, {})
|
||||||
junior.save()
|
junior.save()
|
||||||
|
|
||||||
serializer = self.get_serializer(junior_total_points, many=True)
|
serializer = self.get_serializer(junior_total_points, many=True)
|
||||||
@ -309,11 +310,14 @@ class ApproveTaskAPIView(viewsets.ViewSet):
|
|||||||
"action": str(request.data['action']),
|
"action": str(request.data['action']),
|
||||||
"junior": self.request.data['junior_id']},
|
"junior": self.request.data['junior_id']},
|
||||||
data=request.data)
|
data=request.data)
|
||||||
if str(request.data['action']) == str(NUMBER['one']) and serializer.is_valid():
|
unexpected_task_status = [str(NUMBER['five']), str(NUMBER['six'])]
|
||||||
|
if (str(request.data['action']) == str(NUMBER['one']) and serializer.is_valid()
|
||||||
|
and queryset[1] and queryset[1].task_status not in unexpected_task_status):
|
||||||
# save serializer
|
# save serializer
|
||||||
serializer.save()
|
serializer.save()
|
||||||
return custom_response(SUCCESS_CODE['3025'], response_status=status.HTTP_200_OK)
|
return custom_response(SUCCESS_CODE['3025'], response_status=status.HTTP_200_OK)
|
||||||
elif str(request.data['action']) == str(NUMBER['two']) and serializer.is_valid():
|
elif (str(request.data['action']) == str(NUMBER['two']) and serializer.is_valid()
|
||||||
|
and queryset[1] and queryset[1].task_status not in unexpected_task_status):
|
||||||
# save serializer
|
# save serializer
|
||||||
serializer.save()
|
serializer.save()
|
||||||
return custom_response(SUCCESS_CODE['3026'], response_status=status.HTTP_200_OK)
|
return custom_response(SUCCESS_CODE['3026'], response_status=status.HTTP_200_OK)
|
||||||
|
@ -18,7 +18,8 @@ from account.models import UserEmailOtp, UserNotification
|
|||||||
from junior.utils import junior_notification_email, junior_approval_mail
|
from junior.utils import junior_notification_email, junior_approval_mail
|
||||||
from guardian.utils import real_time, update_referral_points, convert_timedelta_into_datetime
|
from guardian.utils import real_time, update_referral_points, convert_timedelta_into_datetime
|
||||||
from notifications.utils import send_notification
|
from notifications.utils import send_notification
|
||||||
from notifications.constants import INVITED_GUARDIAN, APPROVED_JUNIOR
|
from notifications.constants import (INVITED_GUARDIAN, APPROVED_JUNIOR, SKIPPED_PROFILE_SETUP, TASK_ACTION,
|
||||||
|
TASK_SUBMITTED)
|
||||||
|
|
||||||
|
|
||||||
class ListCharField(serializers.ListField):
|
class ListCharField(serializers.ListField):
|
||||||
@ -284,9 +285,13 @@ class AddJuniorSerializer(serializers.ModelSerializer):
|
|||||||
expiry_time = timezone.now() + timezone.timedelta(days=1)
|
expiry_time = timezone.now() + timezone.timedelta(days=1)
|
||||||
UserEmailOtp.objects.create(email=email, otp=otp_value,
|
UserEmailOtp.objects.create(email=email, otp=otp_value,
|
||||||
user_type='1', expired_at=expiry_time, is_verified=True)
|
user_type='1', expired_at=expiry_time, is_verified=True)
|
||||||
|
# add push notification
|
||||||
|
UserNotification.objects.get_or_create(user=user_data)
|
||||||
"""Notification email"""
|
"""Notification email"""
|
||||||
junior_notification_email(email, full_name, email, password)
|
junior_notification_email(email, full_name, email, password)
|
||||||
junior_approval_mail(guardian, full_name)
|
junior_approval_mail(guardian, full_name)
|
||||||
|
# push notification
|
||||||
|
send_notification.delay(SKIPPED_PROFILE_SETUP, None, junior_data.auth.id, {})
|
||||||
return junior_data
|
return junior_data
|
||||||
|
|
||||||
|
|
||||||
@ -317,6 +322,8 @@ class CompleteTaskSerializer(serializers.ModelSerializer):
|
|||||||
instance.task_status = str(NUMBER['four'])
|
instance.task_status = str(NUMBER['four'])
|
||||||
instance.is_approved = False
|
instance.is_approved = False
|
||||||
instance.save()
|
instance.save()
|
||||||
|
send_notification.delay(TASK_SUBMITTED, None, instance.junior.auth.id, {})
|
||||||
|
send_notification.delay(TASK_ACTION, None, instance.guardian.user.id, {})
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
class JuniorPointsSerializer(serializers.ModelSerializer):
|
class JuniorPointsSerializer(serializers.ModelSerializer):
|
||||||
@ -393,7 +400,7 @@ class AddGuardianSerializer(serializers.ModelSerializer):
|
|||||||
instance.id),
|
instance.id),
|
||||||
referral_code_used=junior_data.referral_code,
|
referral_code_used=junior_data.referral_code,
|
||||||
is_verified=True)
|
is_verified=True)
|
||||||
UserNotification.objects.create(user=instance)
|
UserNotification.objects.get_or_create(user=instance)
|
||||||
return guardian_data
|
return guardian_data
|
||||||
else:
|
else:
|
||||||
user = User.objects.create(username=email, email=email,
|
user = User.objects.create(username=email, email=email,
|
||||||
@ -413,7 +420,7 @@ class AddGuardianSerializer(serializers.ModelSerializer):
|
|||||||
UserEmailOtp.objects.create(email=email, otp=otp_value,
|
UserEmailOtp.objects.create(email=email, otp=otp_value,
|
||||||
user_type=str(NUMBER['two']), expired_at=expiry_time,
|
user_type=str(NUMBER['two']), expired_at=expiry_time,
|
||||||
is_verified=True)
|
is_verified=True)
|
||||||
UserNotification.objects.create(user=user)
|
UserNotification.objects.get_or_create(user=user)
|
||||||
JuniorGuardianRelationship.objects.create(guardian=guardian_data, junior=junior_data,
|
JuniorGuardianRelationship.objects.create(guardian=guardian_data, junior=junior_data,
|
||||||
relationship=relationship)
|
relationship=relationship)
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ from base.constants import NUMBER
|
|||||||
from account.utils import custom_response, custom_error_response
|
from account.utils import custom_response, custom_error_response
|
||||||
from guardian.utils import upload_image_to_alibaba
|
from guardian.utils import upload_image_to_alibaba
|
||||||
from .utils import update_positions_based_on_points
|
from .utils import update_positions_based_on_points
|
||||||
|
from notifications.utils import send_notification
|
||||||
|
from notifications.constants import REMOVE_JUNIOR
|
||||||
|
|
||||||
""" Define APIs """
|
""" Define APIs """
|
||||||
# Define validate guardian code API,
|
# Define validate guardian code API,
|
||||||
@ -233,6 +235,7 @@ class RemoveJuniorAPIView(views.APIView):
|
|||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
# save serializer
|
# save serializer
|
||||||
serializer.save()
|
serializer.save()
|
||||||
|
send_notification.delay(REMOVE_JUNIOR, None, junior_queryset.auth.id, {})
|
||||||
return custom_response(SUCCESS_CODE['3022'], serializer.data, response_status=status.HTTP_200_OK)
|
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)
|
return custom_error_response(serializer.errors, response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
else:
|
else:
|
||||||
@ -374,6 +377,8 @@ class InviteGuardianAPIView(viewsets.ModelViewSet):
|
|||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
""" junior list"""
|
""" junior list"""
|
||||||
try:
|
try:
|
||||||
|
if request.data['email'] == '':
|
||||||
|
return custom_error_response(ERROR_CODE['2062'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
info = {'user': request.user, 'email': request.data['email'], 'first_name': request.data['first_name'],
|
info = {'user': request.user, 'email': request.data['email'], 'first_name': request.data['first_name'],
|
||||||
'last_name': request.data['last_name'], 'relationship': str(request.data['relationship'])}
|
'last_name': request.data['last_name'], 'relationship': str(request.data['relationship'])}
|
||||||
# use AddJuniorSerializer serializer
|
# use AddJuniorSerializer serializer
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
"""
|
"""
|
||||||
notification constants file
|
notification constants file
|
||||||
"""
|
"""
|
||||||
REGISTRATION = 1
|
from base.constants import NUMBER
|
||||||
TASK_CREATED = 2
|
REGISTRATION = NUMBER['one']
|
||||||
INVITED_GUARDIAN = 3
|
TASK_CREATED = NUMBER['two']
|
||||||
APPROVED_JUNIOR = 4
|
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']
|
||||||
TEST_NOTIFICATION = 99
|
TEST_NOTIFICATION = 99
|
||||||
|
|
||||||
NOTIFICATION_DICT = {
|
NOTIFICATION_DICT = {
|
||||||
@ -22,7 +31,39 @@ NOTIFICATION_DICT = {
|
|||||||
},
|
},
|
||||||
APPROVED_JUNIOR: {
|
APPROVED_JUNIOR: {
|
||||||
"title": "Approve junior",
|
"title": "Approve junior",
|
||||||
"body": "You have request for associate the junior"
|
"body": "You have request from junior to associate with you"
|
||||||
|
},
|
||||||
|
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."
|
||||||
|
},
|
||||||
|
SKIPPED_PROFILE_SETUP: {
|
||||||
|
"title": "Skipped profile setup!",
|
||||||
|
"body": "Your guardian has been setup your profile."
|
||||||
|
},
|
||||||
|
TASK_SUBMITTED: {
|
||||||
|
"title": "Task submitted!",
|
||||||
|
"body": "Your task has been submitted successfully."
|
||||||
|
},
|
||||||
|
TASK_ACTION: {
|
||||||
|
"title": "Task approval!",
|
||||||
|
"body": "You have request for task approval."
|
||||||
|
},
|
||||||
|
LEADERBOARD_RANKING: {
|
||||||
|
"title": "Leader board rank!",
|
||||||
|
"body": "Your rank is ."
|
||||||
|
},
|
||||||
|
REMOVE_JUNIOR: {
|
||||||
|
"title": "Disassociate by guardian!",
|
||||||
|
"body": "Your guardian disassociate you ."
|
||||||
},
|
},
|
||||||
TEST_NOTIFICATION: {
|
TEST_NOTIFICATION: {
|
||||||
"title": "Test Notification",
|
"title": "Test Notification",
|
||||||
|
@ -52,7 +52,6 @@ def send_notification(notification_type, from_user_id, to_user_id, extra_data):
|
|||||||
""" used to send the push for the given notification type """
|
""" used to send the push for the given notification type """
|
||||||
(notification_data, from_user, to_user) = get_basic_detail(notification_type, from_user_id, to_user_id)
|
(notification_data, from_user, to_user) = get_basic_detail(notification_type, from_user_id, to_user_id)
|
||||||
user_notification_type = UserNotification.objects.filter(user=to_user).first()
|
user_notification_type = UserNotification.objects.filter(user=to_user).first()
|
||||||
# data = notification_data.data
|
|
||||||
data = notification_data
|
data = notification_data
|
||||||
Notification.objects.create(notification_type=notification_type, notification_from=from_user,
|
Notification.objects.create(notification_type=notification_type, notification_from=from_user,
|
||||||
notification_to=to_user, data=data)
|
notification_to=to_user, data=data)
|
||||||
|
@ -18,7 +18,7 @@ from notifications.utils import send_notification
|
|||||||
|
|
||||||
class NotificationViewSet(viewsets.GenericViewSet):
|
class NotificationViewSet(viewsets.GenericViewSet):
|
||||||
""" used to do the notification actions """
|
""" used to do the notification actions """
|
||||||
serializer_class = None
|
serializer_class = RegisterDevice
|
||||||
permission_classes = [IsAuthenticated, ]
|
permission_classes = [IsAuthenticated, ]
|
||||||
|
|
||||||
@action(methods=['post'], detail=False, url_path='device', url_name='device', serializer_class=RegisterDevice)
|
@action(methods=['post'], detail=False, url_path='device', url_name='device', serializer_class=RegisterDevice)
|
||||||
@ -32,7 +32,7 @@ class NotificationViewSet(viewsets.GenericViewSet):
|
|||||||
serializer.save()
|
serializer.save()
|
||||||
return custom_response(SUCCESS_CODE["3000"])
|
return custom_response(SUCCESS_CODE["3000"])
|
||||||
|
|
||||||
@action(methods=['get'], detail=False, url_path='test', url_name='test', serializer_class=None)
|
@action(methods=['get'], detail=False, url_path='test', url_name='test')
|
||||||
def send_test_notification(self, request):
|
def send_test_notification(self, request):
|
||||||
"""
|
"""
|
||||||
to send test notification
|
to send test notification
|
||||||
|
@ -20,7 +20,7 @@ from guardian.tasks import generate_otp
|
|||||||
USER = get_user_model()
|
USER = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class AdminForgotPasswordSerializer(serializers.ModelSerializer):
|
class AdminOTPSerializer(serializers.ModelSerializer):
|
||||||
"""
|
"""
|
||||||
admin forgot password serializer
|
admin forgot password serializer
|
||||||
"""
|
"""
|
||||||
|
@ -110,7 +110,7 @@ class ArticleViewSet(GenericViewSet, mixins.CreateModelMixin, mixins.UpdateModel
|
|||||||
return custom_error_response(ERROR_CODE["2041"], status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(ERROR_CODE["2041"], status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
@action(methods=['get'], url_name='remove_card', url_path='remove_card',
|
@action(methods=['get'], url_name='remove_card', url_path='remove_card',
|
||||||
detail=True, serializer_class=None)
|
detail=True)
|
||||||
def remove_article_card(self, request, *args, **kwargs):
|
def remove_article_card(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
article card remove (delete) api method
|
article card remove (delete) api method
|
||||||
@ -126,7 +126,7 @@ class ArticleViewSet(GenericViewSet, mixins.CreateModelMixin, mixins.UpdateModel
|
|||||||
return custom_error_response(ERROR_CODE["2042"], response_status=status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(ERROR_CODE["2042"], response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
@action(methods=['get'], url_name='remove_survey', url_path='remove_survey',
|
@action(methods=['get'], url_name='remove_survey', url_path='remove_survey',
|
||||||
detail=True, serializer_class=None)
|
detail=True)
|
||||||
def remove_article_survey(self, request, *args, **kwargs):
|
def remove_article_survey(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
article survey remove (delete) api method
|
article survey remove (delete) api method
|
||||||
@ -170,7 +170,7 @@ class DefaultArticleCardImagesViewSet(GenericViewSet, mixins.CreateModelMixin, m
|
|||||||
api to upload and list default article card images
|
api to upload and list default article card images
|
||||||
"""
|
"""
|
||||||
serializer_class = DefaultArticleCardImageSerializer
|
serializer_class = DefaultArticleCardImageSerializer
|
||||||
# permission_classes = [IsAuthenticated, AdminPermission]
|
permission_classes = [IsAuthenticated, AdminPermission]
|
||||||
queryset = DefaultArticleCardImage.objects.all()
|
queryset = DefaultArticleCardImage.objects.all()
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.auth import get_user_model
|
|||||||
# local imports
|
# local imports
|
||||||
from account.utils import custom_response
|
from account.utils import custom_response
|
||||||
from base.messages import SUCCESS_CODE
|
from base.messages import SUCCESS_CODE
|
||||||
from web_admin.serializers.auth_serializer import (AdminForgotPasswordSerializer, AdminVerifyOTPSerializer,
|
from web_admin.serializers.auth_serializer import (AdminOTPSerializer, AdminVerifyOTPSerializer,
|
||||||
AdminCreatePasswordSerializer)
|
AdminCreatePasswordSerializer)
|
||||||
|
|
||||||
USER = get_user_model()
|
USER = get_user_model()
|
||||||
@ -21,9 +21,9 @@ class ForgotAndResetPasswordViewSet(GenericViewSet):
|
|||||||
"""
|
"""
|
||||||
queryset = None
|
queryset = None
|
||||||
|
|
||||||
@action(methods=['post'], url_name='forgot-password', url_path='forgot-password',
|
@action(methods=['post'], url_name='otp', url_path='otp',
|
||||||
detail=False, serializer_class=AdminForgotPasswordSerializer)
|
detail=False, serializer_class=AdminOTPSerializer)
|
||||||
def admin_forgot_password(self, request):
|
def admin_otp(self, request):
|
||||||
"""
|
"""
|
||||||
api method to send otp
|
api method to send otp
|
||||||
:return: success message
|
:return: success message
|
||||||
@ -44,18 +44,6 @@ class ForgotAndResetPasswordViewSet(GenericViewSet):
|
|||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
return custom_response(SUCCESS_CODE['3011'])
|
return custom_response(SUCCESS_CODE['3011'])
|
||||||
|
|
||||||
@action(methods=['post'], url_name='resend-otp', url_path='resend-otp',
|
|
||||||
detail=False, serializer_class=AdminForgotPasswordSerializer)
|
|
||||||
def admin_resend_otp(self, request):
|
|
||||||
"""
|
|
||||||
api method to resend otp
|
|
||||||
:return: success message
|
|
||||||
"""
|
|
||||||
serializer = self.serializer_class(data=request.data)
|
|
||||||
serializer.is_valid(raise_exception=True)
|
|
||||||
serializer.save()
|
|
||||||
return custom_response(SUCCESS_CODE['3015'])
|
|
||||||
|
|
||||||
@action(methods=['post'], url_name='create-password', url_path='create-password',
|
@action(methods=['post'], url_name='create-password', url_path='create-password',
|
||||||
detail=False, serializer_class=AdminCreatePasswordSerializer)
|
detail=False, serializer_class=AdminCreatePasswordSerializer)
|
||||||
def admin_create_password(self, request):
|
def admin_create_password(self, request):
|
||||||
|
Reference in New Issue
Block a user