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
37f10a38
Commit
37f10a38
authored
Dec 01, 2015
by
Saleem Latif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure web view renders certs only if downloadable.
parent
a0db0d82
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
3 deletions
+51
-3
lms/djangoapps/certificates/tests/test_views.py
+1
-1
lms/djangoapps/certificates/tests/test_webview_views.py
+47
-1
lms/djangoapps/certificates/views/webview.py
+3
-1
No files found.
lms/djangoapps/certificates/tests/test_views.py
View file @
37f10a38
...
...
@@ -215,7 +215,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
grade
=
"0.95"
,
key
=
'the_key'
,
distinction
=
True
,
status
=
'
generated
'
,
status
=
'
downloadable
'
,
mode
=
'honor'
,
name
=
self
.
user
.
profile
.
name
,
)
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
37f10a38
...
...
@@ -89,7 +89,7 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
grade
=
"0.95"
,
key
=
'the_key'
,
distinction
=
True
,
status
=
'
generated
'
,
status
=
'
downloadable
'
,
mode
=
'honor'
,
name
=
self
.
user
.
profile
.
name
,
)
...
...
@@ -342,6 +342,52 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
self
.
assertIn
(
str
(
self
.
cert
.
verify_uuid
),
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_render_certificate_only_for_downloadable_status
(
self
):
"""
Tests taht Certificate HTML Web View returns Certificate only if certificate status is 'downloadable',
for other statuses it should return "Invalid Certificate".
"""
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
)
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
# Validate certificate
response
=
self
.
client
.
get
(
test_url
)
self
.
assertIn
(
str
(
self
.
cert
.
verify_uuid
),
response
.
content
)
# Change status to 'generating' and validate that Certificate Web View returns "Invalid Certificate"
self
.
cert
.
status
=
CertificateStatuses
.
generating
self
.
cert
.
save
()
response
=
self
.
client
.
get
(
test_url
)
self
.
assertIn
(
"Invalid Certificate"
,
response
.
content
)
self
.
assertIn
(
"Cannot Find Certificate"
,
response
.
content
)
self
.
assertIn
(
"We cannot find a certificate with this URL or ID number."
,
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_html_view_for_invalid_certificate
(
self
):
"""
Tests that Certificate HTML Web View returns "Cannot Find Certificate" if certificate has been invalidated.
"""
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
)
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
# Validate certificate
response
=
self
.
client
.
get
(
test_url
)
self
.
assertIn
(
str
(
self
.
cert
.
verify_uuid
),
response
.
content
)
# invalidate certificate and verify that "Cannot Find Certificate" is returned
self
.
cert
.
invalidate
()
response
=
self
.
client
.
get
(
test_url
)
self
.
assertIn
(
"Invalid Certificate"
,
response
.
content
)
self
.
assertIn
(
"Cannot Find Certificate"
,
response
.
content
)
self
.
assertIn
(
"We cannot find a certificate with this URL or ID number."
,
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_render_html_view_with_valid_signatories
(
self
):
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
...
...
lms/djangoapps/certificates/views/webview.py
View file @
37f10a38
...
...
@@ -38,6 +38,7 @@ from certificates.api import (
)
from
certificates.models
import
(
GeneratedCertificate
,
CertificateStatuses
,
CertificateHtmlViewConfiguration
,
CertificateSocialNetworks
,
BadgeAssertion
...
...
@@ -351,7 +352,8 @@ def _get_user_certificate(request, user, course_key, course, preview_mode=None):
else
:
user_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
user
,
course_id
=
course_key
course_id
=
course_key
,
status
=
CertificateStatuses
.
downloadable
)
# If there's no generated certificate data for this user, we need to see if we're in 'preview' mode...
...
...
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