Allow CID users to request details by email

This commit is contained in:
Ross
2023-01-09 13:03:02 +00:00
parent fbaa4b0027
commit 8c8f305f33
6 changed files with 47 additions and 3 deletions
+20
View File
@@ -11,6 +11,9 @@ from django.shortcuts import render, get_object_or_404, redirect
from django.views.decorators.csrf import csrf_exempt
from django import forms
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.utils.html import format_html
# from django.contrib.auth.models import User
@@ -724,3 +727,20 @@ def accounts_bulk_create(request):
return render(request, "accounts_bulk_create.html", context)
else:
return render(request, "accounts_bulk_create.html", {})
def request_cid_details(request):
email = request.POST.get("email")
try:
validate_email(email)
except ValidationError as e:
return HttpResponse("Invalid email.")
cid_users = CidUser.objects.filter(email=email)
for cid_user in cid_users:
cid_user.email_details(resend=True)
cid_user.email_details()
return HttpResponse("Candidate details will be sent to the requested email (if it is found in the system).")