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
4d08cfd4
Commit
4d08cfd4
authored
Sep 10, 2015
by
Zia Fazal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include Null in filters
parent
020e1649
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
6 deletions
+42
-6
lms/djangoapps/certificates/api.py
+6
-0
lms/djangoapps/certificates/tests/test_webview_views.py
+36
-6
No files found.
lms/djangoapps/certificates/api.py
View file @
4d08cfd4
...
...
@@ -14,6 +14,7 @@ from opaque_keys.edx.keys import CourseKey
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
from
xmodule.modulestore.django
import
modulestore
from
xmodule_django.models
import
CourseKeyField
from
util.organizations_helpers
import
get_course_organizations
from
certificates.models
import
(
...
...
@@ -396,6 +397,7 @@ def get_certificate_template(course_key, mode):
if
not
template
and
org_id
and
mode
:
template
=
CertificateTemplate
.
objects
.
filter
(
organization_id
=
org_id
,
course_key
=
CourseKeyField
.
Empty
,
mode
=
mode
,
is_active
=
True
)
...
...
@@ -403,11 +405,15 @@ def get_certificate_template(course_key, mode):
if
not
template
and
org_id
:
template
=
CertificateTemplate
.
objects
.
filter
(
organization_id
=
org_id
,
course_key
=
CourseKeyField
.
Empty
,
mode
=
None
,
is_active
=
True
)
# if we still don't template find by only course mode
if
not
template
and
mode
:
template
=
CertificateTemplate
.
objects
.
filter
(
organization_id
=
None
,
course_key
=
CourseKeyField
.
Empty
,
mode
=
mode
,
is_active
=
True
)
...
...
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
4d08cfd4
...
...
@@ -460,10 +460,11 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
def
test_certificate_custom_template_with_org_mode_course
(
self
):
"""
Tests custom template search and rendering.
This test should check template matching when org={org}, course={course}, mode={mode}.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
self
.
_create_custom_template
(
1
,
mode
=
'honor'
,
course_key
=
unicode
(
self
.
course
.
id
))
self
.
_create_custom_template
(
2
,
mode
=
'honor'
)
self
.
_create_custom_template
(
org_id
=
1
,
mode
=
'honor'
,
course_key
=
unicode
(
self
.
course
.
id
))
self
.
_create_custom_template
(
org_id
=
2
,
mode
=
'honor'
)
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
...
...
@@ -487,11 +488,17 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
@override_settings
(
FEATURES
=
FEATURES_WITH_CUSTOM_CERTS_ENABLED
)
def
test_certificate_custom_template_with_org
(
self
):
"""
Tests custom template search if if have a single template for all courses of organization.
Tests custom template search if we have a single template for organization and mode
with course set to Null.
This test should check template matching when org={org}, course=Null, mode={mode}.
"""
course
=
CourseFactory
.
create
(
org
=
'cstX'
,
number
=
'cst_22'
,
display_name
=
'custom template course'
)
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
self
.
_create_custom_template
(
1
)
self
.
_create_custom_template
(
1
,
mode
=
'honor'
)
self
.
_create_custom_template
(
org_id
=
1
,
mode
=
'honor'
)
self
.
_create_custom_template
(
org_id
=
1
,
mode
=
'honor'
,
course_key
=
course
.
id
)
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
...
...
@@ -506,9 +513,32 @@ class CertificatesViewsTests(ModuleStoreTestCase, EventTrackingTestCase):
self
.
assertContains
(
response
,
'course name: {}'
.
format
(
self
.
course
.
display_name
))
@override_settings
(
FEATURES
=
FEATURES_WITH_CUSTOM_CERTS_ENABLED
)
def
test_certificate_custom_template_with_organization
(
self
):
"""
Tests custom template search when we have a single template for a organization.
This test should check template matching when org={org}, course=Null, mode=null.
"""
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
self
.
_create_custom_template
(
org_id
=
1
,
mode
=
'honor'
)
self
.
_create_custom_template
(
org_id
=
1
,
mode
=
'honor'
,
course_key
=
self
.
course
.
id
)
self
.
_create_custom_template
(
org_id
=
2
)
test_url
=
get_certificate_url
(
user_id
=
self
.
user
.
id
,
course_id
=
unicode
(
self
.
course
.
id
)
)
with
patch
(
'certificates.api.get_course_organizations'
)
as
mock_get_orgs
:
mock_get_orgs
.
side_effect
=
[
[{
"id"
:
2
,
"name"
:
"organization name 2"
}],
]
response
=
self
.
client
.
get
(
test_url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
@override_settings
(
FEATURES
=
FEATURES_WITH_CUSTOM_CERTS_ENABLED
)
def
test_certificate_custom_template_with_course_mode
(
self
):
"""
Tests custom template search if if have a single template for a course mode.
Tests custom template search if we have a single template for a course mode.
This test should check template matching when org=null, course=Null, mode={mode}.
"""
mode
=
'honor'
self
.
_add_course_certificates
(
count
=
1
,
signatory_count
=
2
)
...
...
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