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
a5ddc3bf
Commit
a5ddc3bf
authored
Dec 07, 2015
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Mobile API for PDF certificates and new Course Detail format.
MA-1767
parent
7429a32b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
lms/djangoapps/certificates/api.py
+1
-1
lms/djangoapps/certificates/tests/test_api.py
+12
-1
lms/djangoapps/mobile_api/users/serializers.py
+8
-0
lms/djangoapps/mobile_api/users/tests.py
+25
-1
No files found.
lms/djangoapps/certificates/api.py
View file @
a5ddc3bf
...
@@ -183,7 +183,7 @@ def certificate_downloadable_status(student, course_key):
...
@@ -183,7 +183,7 @@ def certificate_downloadable_status(student, course_key):
if
current_status
[
'status'
]
==
CertificateStatuses
.
downloadable
:
if
current_status
[
'status'
]
==
CertificateStatuses
.
downloadable
:
response_data
[
'is_downloadable'
]
=
True
response_data
[
'is_downloadable'
]
=
True
response_data
[
'download_url'
]
=
get_certificate_url
(
student
.
id
,
course_key
)
response_data
[
'download_url'
]
=
current_status
[
'download_url'
]
or
get_certificate_url
(
student
.
id
,
course_key
)
return
response_data
return
response_data
...
...
lms/djangoapps/certificates/tests/test_api.py
View file @
a5ddc3bf
...
@@ -142,7 +142,11 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
...
@@ -142,7 +142,11 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
}
}
)
)
def
test_with_downloadable_pdf_cert
(
self
):
def
verify_downloadable_pdf_cert
(
self
):
"""
Verifies certificate_downloadable_status returns the
correct response for PDF certificates.
"""
GeneratedCertificateFactory
.
create
(
GeneratedCertificateFactory
.
create
(
user
=
self
.
student
,
user
=
self
.
student
,
course_id
=
self
.
course
.
id
,
course_id
=
self
.
course
.
id
,
...
@@ -161,6 +165,13 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
...
@@ -161,6 +165,13 @@ class CertificateDownloadableStatusTests(WebCertificateTestMixin, ModuleStoreTes
)
)
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
def
test_pdf_cert_with_html_enabled
(
self
):
self
.
verify_downloadable_pdf_cert
()
def
test_pdf_cert_with_html_disabled
(
self
):
self
.
verify_downloadable_pdf_cert
()
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
def
test_with_downloadable_web_cert
(
self
):
def
test_with_downloadable_web_cert
(
self
):
CourseEnrollment
.
enroll
(
self
.
student
,
self
.
course
.
id
,
mode
=
'honor'
)
CourseEnrollment
.
enroll
(
self
.
student
,
self
.
course
.
id
,
mode
=
'honor'
)
self
.
_setup_course_certificate
()
self
.
_setup_course_certificate
()
...
...
lms/djangoapps/mobile_api/users/serializers.py
View file @
a5ddc3bf
...
@@ -55,6 +55,14 @@ class CourseOverviewField(serializers.RelatedField):
...
@@ -55,6 +55,14 @@ class CourseOverviewField(serializers.RelatedField):
)
.
to_json
(),
)
.
to_json
(),
# various URLs
# various URLs
# course_image is sent in both new and old formats
# (within media to be compatible with the new Course API)
'media'
:
{
'course_image'
:
{
'uri'
:
course_overview
.
course_image_url
,
'name'
:
'Course Image'
,
}
},
'course_image'
:
course_overview
.
course_image_url
,
'course_image'
:
course_overview
.
course_image_url
,
'course_about'
:
reverse
(
'course_about'
:
reverse
(
'about_course'
,
'about_course'
,
...
...
lms/djangoapps/mobile_api/users/tests.py
View file @
a5ddc3bf
...
@@ -21,6 +21,7 @@ from courseware.access_response import (
...
@@ -21,6 +21,7 @@ from courseware.access_response import (
VisibilityError
,
VisibilityError
,
)
)
from
course_modes.models
import
CourseMode
from
course_modes.models
import
CourseMode
from
openedx.core.lib.courses
import
course_image_url
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
util.milestones_helpers
import
(
from
util.milestones_helpers
import
(
set_prerequisite_courses
,
set_prerequisite_courses
,
...
@@ -98,6 +99,11 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
...
@@ -98,6 +99,11 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
self
.
assertEqual
(
courses
[
0
][
'mode'
],
CourseMode
.
DEFAULT_MODE_SLUG
)
self
.
assertEqual
(
courses
[
0
][
'mode'
],
CourseMode
.
DEFAULT_MODE_SLUG
)
self
.
assertEqual
(
courses
[
0
][
'course'
][
'subscription_id'
],
self
.
course
.
clean_id
(
padding_char
=
'_'
))
self
.
assertEqual
(
courses
[
0
][
'course'
][
'subscription_id'
],
self
.
course
.
clean_id
(
padding_char
=
'_'
))
expected_course_image_url
=
course_image_url
(
self
.
course
)
self
.
assertIsNotNone
(
expected_course_image_url
)
self
.
assertIn
(
expected_course_image_url
,
found_course
[
'course_image'
])
self
.
assertIn
(
expected_course_image_url
,
found_course
[
'media'
][
'course_image'
][
'uri'
])
def
verify_failure
(
self
,
response
,
error_type
=
None
):
def
verify_failure
(
self
,
response
,
error_type
=
None
):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
courses
=
response
.
data
courses
=
response
.
data
...
@@ -187,7 +193,11 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
...
@@ -187,7 +193,11 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
certificate_data
=
response
.
data
[
0
][
'certificate'
]
certificate_data
=
response
.
data
[
0
][
'certificate'
]
self
.
assertDictEqual
(
certificate_data
,
{})
self
.
assertDictEqual
(
certificate_data
,
{})
def
test_pdf_certificate
(
self
):
def
verify_pdf_certificate
(
self
):
"""
Verifies the correct URL is returned in the response
for PDF certificates.
"""
self
.
login_and_enroll
()
self
.
login_and_enroll
()
certificate_url
=
"http://test_certificate_url"
certificate_url
=
"http://test_certificate_url"
...
@@ -203,6 +213,20 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
...
@@ -203,6 +213,20 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
certificate_data
=
response
.
data
[
0
][
'certificate'
]
certificate_data
=
response
.
data
[
0
][
'certificate'
]
self
.
assertEquals
(
certificate_data
[
'url'
],
certificate_url
)
self
.
assertEquals
(
certificate_data
[
'url'
],
certificate_url
)
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
False
})
def
test_pdf_certificate_with_html_cert_disabled
(
self
):
"""
Tests PDF certificates with CERTIFICATES_HTML_VIEW set to False.
"""
self
.
verify_pdf_certificate
()
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
def
test_pdf_certificate_with_html_cert_enabled
(
self
):
"""
Tests PDF certificates with CERTIFICATES_HTML_VIEW set to True.
"""
self
.
verify_pdf_certificate
()
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'CERTIFICATES_HTML_VIEW'
:
True
})
def
test_web_certificate
(
self
):
def
test_web_certificate
(
self
):
self
.
login_and_enroll
()
self
.
login_and_enroll
()
...
...
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