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
da675e52
Commit
da675e52
authored
Nov 20, 2017
by
Ahsan Ulhaq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Learner certificates should not be findable before the available date
LEARNER-3298
parent
dcb77ff7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
common/test/acceptance/tests/lms/test_certificate_web_view.py
+2
-1
lms/djangoapps/certificates/tests/test_webview_views.py
+30
-2
lms/djangoapps/certificates/views/webview.py
+8
-1
No files found.
common/test/acceptance/tests/lms/test_certificate_web_view.py
View file @
da675e52
...
...
@@ -43,7 +43,8 @@ class CertificateWebViewTest(EventsTestMixin, UniqueCourseTest):
settings
=
course_settings
)
self
.
course_fixture
.
add_advanced_settings
({
"cert_html_view_enabled"
:
{
"value"
:
"true"
}
"cert_html_view_enabled"
:
{
"value"
:
"true"
},
"certificates_display_behavior"
:
{
"value"
:
"early_with_info"
},
})
self
.
course_fixture
.
install
()
self
.
user_id
=
"99"
# we have created a user with this id in fixture
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
da675e52
...
...
@@ -657,6 +657,35 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
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_non_viewable_certificate
(
self
):
"""
Tests that Certificate HTML Web View returns "Cannot Find Certificate" if certificate is not viewable yet.
"""
test_certificates
=
[
{
'id'
:
0
,
'name'
:
'Certificate Name 0'
,
'signatories'
:
[],
'version'
:
1
,
'is_active'
:
True
}
]
self
.
course
.
certificates
=
{
'certificates'
:
test_certificates
}
self
.
course
.
cert_html_view_enabled
=
True
self
.
course
.
certificate_available_date
=
datetime
.
datetime
.
today
()
+
datetime
.
timedelta
(
days
=
1
)
self
.
course
.
save
()
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
)
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
):
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
test_url
=
get_certificate_url
(
...
...
@@ -871,8 +900,7 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
@ddt.data
(
(
-
2
,
True
),
(
-
2
,
False
),
(
10
,
False
)
(
-
2
,
False
)
)
@ddt.unpack
def
test_html_view_certificate_available_date_for_instructor_paced_courses
(
self
,
cert_avail_delta
,
self_paced
):
...
...
lms/djangoapps/certificates/views/webview.py
View file @
da675e52
...
...
@@ -43,7 +43,7 @@ from openedx.core.djangoapps.catalog.utils import get_course_run_details
from
openedx.core.djangoapps.lang_pref.api
import
released_languages
from
openedx.core.djangoapps.site_configuration
import
helpers
as
configuration_helpers
from
openedx.core.lib.courses
import
course_image_url
from
openedx.core.djangoapps.certificates.api
import
display_date_for_certificate
from
openedx.core.djangoapps.certificates.api
import
display_date_for_certificate
,
certificates_viewable_for_course
from
student.models
import
LinkedInAddToProfileConfiguration
from
util
import
organizations_helpers
as
organization_api
from
util.date_utils
import
strftime_localized
...
...
@@ -516,6 +516,13 @@ def render_html_view(request, user_id, course_id):
log
.
info
(
error_str
,
course_id
,
user_id
,
str
(
exception
))
return
_render_invalid_certificate
(
course_id
,
platform_name
,
configuration
)
if
not
certificates_viewable_for_course
(
course
):
log
.
info
(
"Invalid cert: Certificate for
%
s is not viewable yet."
,
course_id
,
)
return
_render_invalid_certificate
(
course_id
,
platform_name
,
configuration
)
# Kick the user back to the "Invalid" screen if the feature is disabled for the course
if
not
course
.
cert_html_view_enabled
:
log
.
info
(
...
...
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