Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
98878554
Commit
98878554
authored
Dec 19, 2014
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6311 from edx/renzo/photo-submission-confirmation-email
Send confirmation email on successful photo submission
parents
368dbf2e
1e4f8901
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
lms/djangoapps/verify_student/tests/test_views.py
+10
-0
lms/djangoapps/verify_student/views.py
+21
-2
lms/templates/emails/photo_submission_confirmation.txt
+11
-0
No files found.
lms/djangoapps/verify_student/tests/test_views.py
View file @
98878554
...
...
@@ -25,6 +25,7 @@ from django.test.utils import override_settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core
import
mail
from
bs4
import
BeautifulSoup
from
util.testing
import
UrlResetMixin
...
...
@@ -923,6 +924,15 @@ class TestSubmitPhotosForVerification(UrlResetMixin, TestCase):
response
=
self
.
client
.
post
(
url
,
params
)
self
.
assertEqual
(
response
.
status_code
,
expected_status_code
)
if
expected_status_code
==
200
:
# Verify that photo submission confirmation email was sent
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
"Verification photos received"
,
mail
.
outbox
[
0
]
.
subject
)
else
:
# Verify that photo submission confirmation email was not sent
self
.
assertEqual
(
len
(
mail
.
outbox
),
0
)
return
response
def
_assert_full_name
(
self
,
full_name
):
...
...
lms/djangoapps/verify_student/views.py
View file @
98878554
...
...
@@ -9,7 +9,7 @@ import datetime
from
collections
import
namedtuple
from
pytz
import
UTC
from
edxmako.shortcuts
import
render_to_response
from
edxmako.shortcuts
import
render_to_response
,
render_to_string
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
...
...
@@ -24,6 +24,7 @@ from django.views.generic.base import View
from
django.utils.decorators
import
method_decorator
from
django.utils.translation
import
ugettext
as
_
,
ugettext_lazy
from
django.contrib.auth.decorators
import
login_required
from
django.core.mail
import
send_mail
from
openedx.core.djangoapps.user_api.api
import
profile
as
profile_api
...
...
@@ -43,6 +44,7 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
from
opaque_keys.edx.keys
import
CourseKey
from
.exceptions
import
WindowExpiredException
from
xmodule.modulestore.django
import
modulestore
from
microsite_configuration
import
microsite
from
util.json_request
import
JsonResponse
...
...
@@ -850,12 +852,14 @@ def submit_photos_for_verification(request):
if
SoftwareSecurePhotoVerification
.
user_has_valid_or_pending
(
request
.
user
):
return
HttpResponseBadRequest
(
_
(
"You already have a valid or pending verification."
))
username
=
request
.
user
.
username
# If the user wants to change his/her full name,
# then try to do that before creating the attempt.
if
request
.
POST
.
get
(
'full_name'
):
try
:
profile_api
.
update_profile
(
request
.
user
.
username
,
username
,
full_name
=
request
.
POST
.
get
(
'full_name'
)
)
except
profile_api
.
ProfileUserNotFound
:
...
...
@@ -880,6 +884,21 @@ def submit_photos_for_verification(request):
attempt
.
mark_ready
()
attempt
.
submit
()
profile_dict
=
profile_api
.
profile_info
(
username
)
if
profile_dict
:
# Send a confirmation email to the user
context
=
{
'full_name'
:
profile_dict
.
get
(
'full_name'
),
'platform_name'
:
settings
.
PLATFORM_NAME
}
subject
=
_
(
"Verification photos received"
)
message
=
render_to_string
(
'emails/photo_submission_confirmation.txt'
,
context
)
from_address
=
microsite
.
get_value
(
'default_from_email'
,
settings
.
DEFAULT_FROM_EMAIL
)
to_address
=
profile_dict
.
get
(
'email'
)
send_mail
(
subject
,
message
,
from_address
,
[
to_address
],
fail_silently
=
False
)
return
HttpResponse
(
200
)
...
...
lms/templates/emails/photo_submission_confirmation.txt
0 → 100644
View file @
98878554
<%! from django.utils.translation import ugettext as _ %>
${_("Hi {full_name},").format(full_name=full_name)}
${_("Thanks for submitting your photos!")}
${_("We've received your information and the verification process has begun. You can check the status of the verification process on your dashboard.")}
${_("Thank you,")}
${_("The {platform_name} team").format(platform_name=platform_name)}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment