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
6fca86a7
Commit
6fca86a7
authored
Dec 01, 2015
by
Matt Drayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10777 from edx/saleem-latif/SOL-1466
SOL-1466: Make sure web view renders certs only if downloadable.
parents
11f34c1e
37f10a38
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 @
6fca86a7
...
@@ -215,7 +215,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
...
@@ -215,7 +215,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
grade
=
"0.95"
,
grade
=
"0.95"
,
key
=
'the_key'
,
key
=
'the_key'
,
distinction
=
True
,
distinction
=
True
,
status
=
'
generated
'
,
status
=
'
downloadable
'
,
mode
=
'honor'
,
mode
=
'honor'
,
name
=
self
.
user
.
profile
.
name
,
name
=
self
.
user
.
profile
.
name
,
)
)
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
6fca86a7
...
@@ -89,7 +89,7 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
...
@@ -89,7 +89,7 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
grade
=
"0.95"
,
grade
=
"0.95"
,
key
=
'the_key'
,
key
=
'the_key'
,
distinction
=
True
,
distinction
=
True
,
status
=
'
generated
'
,
status
=
'
downloadable
'
,
mode
=
'honor'
,
mode
=
'honor'
,
name
=
self
.
user
.
profile
.
name
,
name
=
self
.
user
.
profile
.
name
,
)
)
...
@@ -342,6 +342,52 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
...
@@ -342,6 +342,52 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
self
.
assertIn
(
str
(
self
.
cert
.
verify_uuid
),
response
.
content
)
self
.
assertIn
(
str
(
self
.
cert
.
verify_uuid
),
response
.
content
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
@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
):
def
test_render_html_view_with_valid_signatories
(
self
):
test_url
=
get_certificate_url
(
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
user_id
=
self
.
user
.
id
,
...
...
lms/djangoapps/certificates/views/webview.py
View file @
6fca86a7
...
@@ -38,6 +38,7 @@ from certificates.api import (
...
@@ -38,6 +38,7 @@ from certificates.api import (
)
)
from
certificates.models
import
(
from
certificates.models
import
(
GeneratedCertificate
,
GeneratedCertificate
,
CertificateStatuses
,
CertificateHtmlViewConfiguration
,
CertificateHtmlViewConfiguration
,
CertificateSocialNetworks
,
CertificateSocialNetworks
,
BadgeAssertion
BadgeAssertion
...
@@ -351,7 +352,8 @@ def _get_user_certificate(request, user, course_key, course, preview_mode=None):
...
@@ -351,7 +352,8 @@ def _get_user_certificate(request, user, course_key, course, preview_mode=None):
else
:
else
:
user_certificate
=
GeneratedCertificate
.
objects
.
get
(
user_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
user
,
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...
# 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