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
115b1692
Commit
115b1692
authored
Dec 12, 2015
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/SOL-1519: Include course-level configuration in feature check
parent
5386d0a4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
111 additions
and
54 deletions
+111
-54
common/djangoapps/student/tests/test_certificates.py
+3
-3
common/djangoapps/student/views.py
+1
-1
lms/djangoapps/certificates/api.py
+37
-12
lms/djangoapps/certificates/tests/test_support_views.py
+27
-2
lms/djangoapps/certificates/tests/test_views.py
+3
-0
lms/djangoapps/certificates/tests/test_webview_views.py
+37
-33
lms/djangoapps/certificates/views/webview.py
+1
-1
lms/djangoapps/courseware/tests/test_views.py
+1
-1
lms/djangoapps/courseware/views.py
+1
-1
No files found.
common/djangoapps/student/tests/test_certificates.py
View file @
115b1692
...
...
@@ -82,9 +82,6 @@ class CertificateDisplayTest(ModuleStoreTestCase):
@override_settings
(
CERT_NAME_SHORT
=
'Test_Certificate'
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
def
test_linked_student_to_web_view_credential
(
self
,
enrollment_mode
):
cert
=
self
.
_create_certificate
(
enrollment_mode
)
test_url
=
get_certificate_url
(
uuid
=
cert
.
verify_uuid
)
certificates
=
[
{
'id'
:
0
,
...
...
@@ -100,6 +97,9 @@ class CertificateDisplayTest(ModuleStoreTestCase):
self
.
course
.
save
()
# pylint: disable=no-member
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
cert
=
self
.
_create_certificate
(
enrollment_mode
)
test_url
=
get_certificate_url
(
course_id
=
self
.
course
.
id
,
uuid
=
cert
.
verify_uuid
)
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertContains
(
response
,
u'View Test_Certificate'
)
...
...
common/djangoapps/student/views.py
View file @
115b1692
...
...
@@ -340,7 +340,7 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa
if
course_overview
.
has_any_active_web_certificate
:
status_dict
.
update
({
'show_cert_web_view'
:
True
,
'cert_web_view_url'
:
get_certificate_url
(
uuid
=
cert_status
[
'uuid'
])
'cert_web_view_url'
:
get_certificate_url
(
course_id
=
course_overview
.
id
,
uuid
=
cert_status
[
'uuid'
])
})
else
:
# don't show download certificate button if we don't have an active certificate for course
...
...
lms/djangoapps/certificates/api.py
View file @
115b1692
...
...
@@ -10,6 +10,7 @@ from django.conf import settings
from
django.core.urlresolvers
import
reverse
from
eventtracking
import
tracker
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
...
...
@@ -288,16 +289,33 @@ def has_html_certificates_enabled(course_key, course=None):
of one.
course (CourseDescriptor|CourseOverview): A course.
"""
html_certificates_enabled
=
False
try
:
# If the feature is disabled, then immediately return a False
if
not
settings
.
FEATURES
.
get
(
'CERTIFICATES_HTML_VIEW'
,
False
):
return
False
# If we don't have a course object, we'll need to assemble one
if
not
course
:
# Initialize a course key if necessary
if
not
isinstance
(
course_key
,
CourseKey
):
course_key
=
CourseKey
.
from_string
(
course_key
)
course
=
course
if
course
else
CourseOverview
.
get_from_id
(
course_key
)
if
settings
.
FEATURES
.
get
(
'CERTIFICATES_HTML_VIEW'
,
False
)
and
course
.
cert_html_view_enabled
:
html_certificates_enabled
=
True
except
:
# pylint: disable=bare-except
pass
return
html_certificates_enabled
try
:
course_key
=
CourseKey
.
from_string
(
course_key
)
except
InvalidKeyError
:
log
.
warning
(
(
'Unable to parse course_key "
%
s"'
,
course_key
),
exc_info
=
True
)
return
False
# Pull the course data from the cache
try
:
course
=
CourseOverview
.
get_from_id
(
course_key
)
except
:
# pylint: disable=bare-except
log
.
warning
(
(
'Unable to load CourseOverview object for course_key "
%
s"'
,
unicode
(
course_key
)),
exc_info
=
True
)
# Return the flag on the course object
return
course
.
cert_html_view_enabled
if
course
else
False
def
example_certificates_status
(
course_key
):
...
...
@@ -341,7 +359,7 @@ def get_certificate_url(user_id=None, course_id=None, uuid=None):
new uuid based cert url url otherwise old url.
"""
url
=
""
if
settings
.
FEATURES
.
get
(
'CERTIFICATES_HTML_VIEW'
,
False
):
if
has_html_certificates_enabled
(
course_id
):
if
uuid
:
url
=
reverse
(
'certificates:render_cert_by_uuid'
,
...
...
@@ -356,9 +374,16 @@ def get_certificate_url(user_id=None, course_id=None, uuid=None):
}
)
else
:
try
:
if
isinstance
(
course_id
,
basestring
)
:
if
isinstance
(
course_id
,
basestring
)
:
try
:
course_id
=
CourseKey
.
from_string
(
course_id
)
except
InvalidKeyError
:
log
.
warning
(
(
'Unable to parse course_id "
%
s"'
,
course_id
),
exc_info
=
True
)
return
url
try
:
user_certificate
=
GeneratedCertificate
.
objects
.
get
(
user
=
user_id
,
course_id
=
course_id
...
...
lms/djangoapps/certificates/tests/test_support_views.py
View file @
115b1692
...
...
@@ -79,10 +79,34 @@ class CertificateSupportTestCase(TestCase):
@ddt.ddt
class
CertificateSearchTests
(
CertificateSupportTestCase
):
class
CertificateSearchTests
(
ModuleStoreTestCase
,
CertificateSupportTestCase
):
"""
Tests for the certificate search end-point used by the support team.
"""
def
setUp
(
self
):
"""
Create a course
"""
super
(
CertificateSearchTests
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
()
self
.
course
.
cert_html_view_enabled
=
True
#course certificate configurations
certificates
=
[
{
'id'
:
1
,
'name'
:
'Name 1'
,
'description'
:
'Description 1'
,
'course_title'
:
'course_title_1'
,
'signatories'
:
[],
'version'
:
1
,
'is_active'
:
True
}
]
self
.
course
.
certificates
=
{
'certificates'
:
certificates
}
self
.
course
.
save
()
# pylint: disable=no-member
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
@ddt.data
(
(
GlobalStaff
,
True
),
...
...
@@ -141,6 +165,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
@override_settings
(
FEATURES
=
FEATURES_WITH_CERTS_ENABLED
)
def
test_download_link
(
self
):
self
.
cert
.
course_id
=
self
.
course
.
id
# pylint: disable=no-member
self
.
cert
.
download_url
=
''
self
.
cert
.
save
()
...
...
@@ -155,7 +180,7 @@ class CertificateSearchTests(CertificateSupportTestCase):
retrieved_cert
[
"download_url"
],
reverse
(
'certificates:html_view'
,
kwargs
=
{
"user_id"
:
self
.
student
.
id
,
"course_id"
:
self
.
CERT_COURSE_KEY
}
# pylint: disable=no-member
kwargs
=
{
"user_id"
:
self
.
student
.
id
,
"course_id"
:
self
.
course
.
id
}
# pylint: disable=no-member
)
)
...
...
lms/djangoapps/certificates/tests/test_views.py
View file @
115b1692
...
...
@@ -198,6 +198,9 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
self
.
course
=
CourseFactory
.
create
(
org
=
'testorg'
,
number
=
'run1'
,
display_name
=
'refundable course'
)
self
.
course
.
cert_html_view_enabled
=
True
self
.
course
.
save
()
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
self
.
course_id
=
self
.
course
.
location
.
course_key
self
.
user
=
UserFactory
.
create
(
email
=
'joe_user@edx.org'
,
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
115b1692
This diff is collapsed.
Click to expand it.
lms/djangoapps/certificates/views/webview.py
View file @
115b1692
...
...
@@ -271,7 +271,7 @@ def _update_social_context(request, context, course, user, user_certificate, pla
)
)
share_url
=
request
.
build_absolute_uri
(
get_certificate_url
(
uuid
=
user_certificate
.
verify_uuid
))
share_url
=
request
.
build_absolute_uri
(
get_certificate_url
(
course_id
=
course
.
id
,
uuid
=
user_certificate
.
verify_uuid
))
context
[
'share_url'
]
=
share_url
twitter_url
=
''
if
context
.
get
(
'twitter_share_enabled'
,
False
):
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
115b1692
...
...
@@ -910,7 +910,7 @@ class ProgressPageTests(ModuleStoreTestCase):
self
.
assertContains
(
resp
,
u"View Certificate"
)
self
.
assertContains
(
resp
,
u"You can keep working for a higher grade"
)
cert_url
=
certs_api
.
get_certificate_url
(
uuid
=
certificate
.
verify_uuid
)
cert_url
=
certs_api
.
get_certificate_url
(
course_id
=
self
.
course
.
id
,
uuid
=
certificate
.
verify_uuid
)
self
.
assertContains
(
resp
,
cert_url
)
# when course certificate is not active
...
...
lms/djangoapps/courseware/views.py
View file @
115b1692
...
...
@@ -980,7 +980,7 @@ def _progress(request, course_key, student_id):
if
certs_api
.
get_active_web_certificate
(
course
)
is
not
None
:
context
.
update
({
'show_cert_web_view'
:
True
,
'cert_web_view_url'
:
certs_api
.
get_certificate_url
(
uuid
=
cert_status
[
'uuid'
]),
'cert_web_view_url'
:
certs_api
.
get_certificate_url
(
course_id
=
course_key
,
uuid
=
cert_status
[
'uuid'
]),
})
else
:
context
.
update
({
...
...
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