Support email

This commit is contained in:
jain
2023-07-11 16:33:03 +05:30
parent 8b4db3e2e9
commit efa121640f
7 changed files with 67 additions and 6 deletions

View File

@ -5,6 +5,7 @@ from rest_framework import viewsets, status, views
from rest_framework.decorators import action
import random
import logging
from django.views.decorators.csrf import csrf_exempt
from django.utils import timezone
import jwt
"""App Import"""
@ -23,8 +24,7 @@ from .serializers import (SuperUserSerializer, GuardianSerializer, JuniorSeriali
from rest_framework_simplejwt.tokens import RefreshToken
from base.messages import ERROR_CODE, SUCCESS_CODE
from guardian.tasks import generate_otp
from account.utils import send_otp_email
from account.utils import custom_response, custom_error_response
from account.utils import send_otp_email, send_support_email, custom_response, custom_error_response
from rest_framework.permissions import IsAuthenticated
from templated_email import send_templated_mail
import google.oauth2.credentials
@ -461,3 +461,19 @@ class UpdateUserNotificationAPIViewSet(viewsets.ModelViewSet):
serializer.save()
return custom_response(None, serializer.data, response_status=status.HTTP_200_OK)
return custom_error_response(serializer.error, response_status=status.HTTP_400_BAD_REQUEST)
class SendSupportEmail(views.APIView):
def post(self, request):
name = request.data.get('name')
sender = request.data.get('email')
subject = request.data.get('subject')
message = request.data.get('message')
if name and sender and subject and message:
try:
send_support_email(name, sender, subject, message)
return custom_response(SUCCESS_CODE['3019'], response_status=status.HTTP_200_OK)
except Exception as e:
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
else:
return custom_error_response(ERROR_CODE['2033'], response_status=status.HTTP_400_BAD_REQUEST)