Commit e23ee31b by John Jarvis Committed by Bridger Maxwell

added email validation for certificate request

parent 7ce3c5b9
...@@ -5,10 +5,11 @@ import uuid ...@@ -5,10 +5,11 @@ import uuid
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
import courseware.grades as grades import courseware.grades as grades
from certificates.models import GeneratedCertificate from certificates.models import GeneratedCertificate
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
log = logging.getLogger("mitx.certificates") log = logging.getLogger("mitx.certificates")
...@@ -32,11 +33,10 @@ def certificate_request(request): ...@@ -32,11 +33,10 @@ def certificate_request(request):
if verification_checked != 'true': if verification_checked != 'true':
error += 'You must verify that you have followed the honor code to receive a certificate. ' error += 'You must verify that you have followed the honor code to receive a certificate. '
try:
# TODO: Check e-mail format is correct. validate_email(destination_email)
if len(destination_email) < 5: except ValidationError:
error += 'Please provide a valid email address to send the certificate. ' error += 'Please provide a valid email address to send the certificate. '
grade = None grade = None
if len(error) == 0: if len(error) == 0:
student_gradesheet = grades.grade_sheet(request.user) student_gradesheet = grades.grade_sheet(request.user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment