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
6e14461a
Commit
6e14461a
authored
Jan 11, 2016
by
Tasawer
Committed by
Ahsan Ulhaq
Jan 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 'certificate_url' field for view certificate on learner dashboard.
ECOM-3281
parent
8fb998fe
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
25 deletions
+25
-25
openedx/core/djangoapps/credentials/tests/mixins.py
+16
-8
openedx/core/djangoapps/credentials/tests/test_utils.py
+1
-5
openedx/core/djangoapps/programs/tests/mixins.py
+6
-2
openedx/core/djangoapps/programs/tests/test_utils.py
+1
-5
openedx/core/djangoapps/programs/utils.py
+1
-5
No files found.
openedx/core/djangoapps/credentials/tests/mixins.py
View file @
6e14461a
...
@@ -41,7 +41,8 @@ class CredentialsDataMixin(object):
...
@@ -41,7 +41,8 @@ class CredentialsDataMixin(object):
"program_id"
:
1
"program_id"
:
1
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-1"
"uuid"
:
"dummy-uuid-1"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-1/"
},
},
{
{
"id"
:
2
,
"id"
:
2
,
...
@@ -51,7 +52,8 @@ class CredentialsDataMixin(object):
...
@@ -51,7 +52,8 @@ class CredentialsDataMixin(object):
"program_id"
:
2
"program_id"
:
2
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-2"
"uuid"
:
"dummy-uuid-2"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-2/"
},
},
{
{
"id"
:
3
,
"id"
:
3
,
...
@@ -61,7 +63,8 @@ class CredentialsDataMixin(object):
...
@@ -61,7 +63,8 @@ class CredentialsDataMixin(object):
"program_id"
:
3
"program_id"
:
3
},
},
"status"
:
"revoked"
,
"status"
:
"revoked"
,
"uuid"
:
"dummy-uuid-3"
"uuid"
:
"dummy-uuid-3"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-3/"
},
},
{
{
"id"
:
4
,
"id"
:
4
,
...
@@ -72,7 +75,8 @@ class CredentialsDataMixin(object):
...
@@ -72,7 +75,8 @@ class CredentialsDataMixin(object):
"certificate_type"
:
"honor"
"certificate_type"
:
"honor"
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-4"
"uuid"
:
"dummy-uuid-4"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-4/"
},
},
{
{
"id"
:
5
,
"id"
:
5
,
...
@@ -83,7 +87,8 @@ class CredentialsDataMixin(object):
...
@@ -83,7 +87,8 @@ class CredentialsDataMixin(object):
"certificate_type"
:
"verified"
"certificate_type"
:
"verified"
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-5"
"uuid"
:
"dummy-uuid-5"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-5/"
},
},
{
{
"id"
:
6
,
"id"
:
6
,
...
@@ -94,7 +99,8 @@ class CredentialsDataMixin(object):
...
@@ -94,7 +99,8 @@ class CredentialsDataMixin(object):
"certificate_type"
:
"honor"
"certificate_type"
:
"honor"
},
},
"status"
:
"revoked"
,
"status"
:
"revoked"
,
"uuid"
:
"dummy-uuid-6"
"uuid"
:
"dummy-uuid-6"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-6/"
}
}
]
]
}
}
...
@@ -110,7 +116,8 @@ class CredentialsDataMixin(object):
...
@@ -110,7 +116,8 @@ class CredentialsDataMixin(object):
"program_id"
:
7
"program_id"
:
7
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-7"
"uuid"
:
"dummy-uuid-7"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-7"
},
},
{
{
"id"
:
8
,
"id"
:
8
,
...
@@ -120,7 +127,8 @@ class CredentialsDataMixin(object):
...
@@ -120,7 +127,8 @@ class CredentialsDataMixin(object):
"program_id"
:
8
"program_id"
:
8
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-8"
"uuid"
:
"dummy-uuid-8"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-8/"
}
}
]
]
}
}
...
...
openedx/core/djangoapps/credentials/tests/test_utils.py
View file @
6e14461a
...
@@ -80,7 +80,7 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
...
@@ -80,7 +80,7 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
def
test_get_user_programs_credentials
(
self
):
def
test_get_user_programs_credentials
(
self
):
"""Verify program credentials data can be retrieved and parsed correctly."""
"""Verify program credentials data can be retrieved and parsed correctly."""
# create credentials and program configuration
# create credentials and program configuration
credentials_config
=
self
.
create_credentials_config
()
self
.
create_credentials_config
()
self
.
create_programs_config
()
self
.
create_programs_config
()
# Mocking the API responses from programs and credentials
# Mocking the API responses from programs and credentials
...
@@ -89,10 +89,6 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
...
@@ -89,10 +89,6 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
actual
=
get_user_program_credentials
(
self
.
user
)
actual
=
get_user_program_credentials
(
self
.
user
)
expected
=
self
.
PROGRAMS_API_RESPONSE
[
'results'
]
expected
=
self
.
PROGRAMS_API_RESPONSE
[
'results'
]
expected
[
0
][
'credential_url'
]
=
\
credentials_config
.
public_service_url
+
'credentials/'
+
self
.
PROGRAMS_CREDENTIALS_DATA
[
0
][
'uuid'
]
expected
[
1
][
'credential_url'
]
=
\
credentials_config
.
public_service_url
+
'credentials/'
+
self
.
PROGRAMS_CREDENTIALS_DATA
[
1
][
'uuid'
]
# checking response from API is as expected
# checking response from API is as expected
self
.
assertEqual
(
len
(
actual
),
2
)
self
.
assertEqual
(
len
(
actual
),
2
)
...
...
openedx/core/djangoapps/programs/tests/mixins.py
View file @
6e14461a
...
@@ -56,6 +56,7 @@ class ProgramsDataMixin(object):
...
@@ -56,6 +56,7 @@ class ProgramsDataMixin(object):
'category'
:
'xseries'
,
'category'
:
'xseries'
,
'status'
:
'unpublished'
,
'status'
:
'unpublished'
,
'marketing_slug'
:
''
,
'marketing_slug'
:
''
,
'credential_url'
:
'http://credentials.edx.org/credentials/dummy-uuid-1/'
,
'organizations'
:
[
'organizations'
:
[
{
{
'display_name'
:
'Test Organization A'
,
'display_name'
:
'Test Organization A'
,
...
@@ -122,6 +123,7 @@ class ProgramsDataMixin(object):
...
@@ -122,6 +123,7 @@ class ProgramsDataMixin(object):
'category'
:
'xseries'
,
'category'
:
'xseries'
,
'status'
:
'unpublished'
,
'status'
:
'unpublished'
,
'marketing_slug'
:
''
,
'marketing_slug'
:
''
,
'credential_url'
:
'http://credentials.edx.org/credentials/dummy-uuid-2/'
,
'organizations'
:
[
'organizations'
:
[
{
{
'display_name'
:
'Test Organization B'
,
'display_name'
:
'Test Organization B'
,
...
@@ -193,7 +195,8 @@ class ProgramsDataMixin(object):
...
@@ -193,7 +195,8 @@ class ProgramsDataMixin(object):
"program_id"
:
1
"program_id"
:
1
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-1"
"uuid"
:
"dummy-uuid-1"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-1/"
},
},
{
{
"id"
:
2
,
"id"
:
2
,
...
@@ -203,7 +206,8 @@ class ProgramsDataMixin(object):
...
@@ -203,7 +206,8 @@ class ProgramsDataMixin(object):
"program_id"
:
2
"program_id"
:
2
},
},
"status"
:
"awarded"
,
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-2"
"uuid"
:
"dummy-uuid-2"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-2/"
}
}
]
]
...
...
openedx/core/djangoapps/programs/tests/test_utils.py
View file @
6e14461a
...
@@ -137,15 +137,11 @@ class TestProgramRetrieval(ProgramsApiConfigMixin, ProgramsDataMixin,
...
@@ -137,15 +137,11 @@ class TestProgramRetrieval(ProgramsApiConfigMixin, ProgramsDataMixin,
def
test_get_program_for_certificates
(
self
):
def
test_get_program_for_certificates
(
self
):
"""Verify programs data can be retrieved and parsed correctly for certificates."""
"""Verify programs data can be retrieved and parsed correctly for certificates."""
self
.
create_programs_config
()
self
.
create_programs_config
()
credentials_config
=
self
.
create_credentials_config
()
self
.
mock_programs_api
()
self
.
mock_programs_api
()
actual
=
get_programs_for_credentials
(
self
.
user
,
self
.
PROGRAMS_CREDENTIALS_DATA
)
actual
=
get_programs_for_credentials
(
self
.
user
,
self
.
PROGRAMS_CREDENTIALS_DATA
)
expected
=
self
.
PROGRAMS_API_RESPONSE
[
'results'
]
expected
=
self
.
PROGRAMS_API_RESPONSE
[
'results'
]
expected
[
0
][
'credential_url'
]
=
\
credentials_config
.
public_service_url
+
'credentials/'
+
self
.
PROGRAMS_CREDENTIALS_DATA
[
0
][
'uuid'
]
expected
[
1
][
'credential_url'
]
=
\
credentials_config
.
public_service_url
+
'credentials/'
+
self
.
PROGRAMS_CREDENTIALS_DATA
[
1
][
'uuid'
]
self
.
assertEqual
(
len
(
actual
),
2
)
self
.
assertEqual
(
len
(
actual
),
2
)
self
.
assertEqual
(
actual
,
expected
)
self
.
assertEqual
(
actual
,
expected
)
...
...
openedx/core/djangoapps/programs/utils.py
View file @
6e14461a
"""Helper functions for working with Programs."""
"""Helper functions for working with Programs."""
import
logging
import
logging
from
urlparse
import
urljoin
from
openedx.core.djangoapps.credentials.models
import
CredentialsApiConfig
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.lib.edx_api_utils
import
get_edx_api_data
from
openedx.core.lib.edx_api_utils
import
get_edx_api_data
...
@@ -98,12 +96,10 @@ def get_programs_for_credentials(user, programs_credentials):
...
@@ -98,12 +96,10 @@ def get_programs_for_credentials(user, programs_credentials):
log
.
debug
(
'No programs found for the user with ID
%
d.'
,
user
.
id
)
log
.
debug
(
'No programs found for the user with ID
%
d.'
,
user
.
id
)
return
certificate_programs
return
certificate_programs
credential_configuration
=
CredentialsApiConfig
.
current
()
for
program
in
programs
:
for
program
in
programs
:
for
credential
in
programs_credentials
:
for
credential
in
programs_credentials
:
if
program
[
'id'
]
==
credential
[
'credential'
][
'program_id'
]:
if
program
[
'id'
]
==
credential
[
'credential'
][
'program_id'
]:
credentials_url
=
'credentials/'
+
credential
[
'uuid'
]
program
[
'credential_url'
]
=
credential
[
'certificate_url'
]
program
[
'credential_url'
]
=
urljoin
(
credential_configuration
.
public_service_url
,
credentials_url
)
certificate_programs
.
append
(
program
)
certificate_programs
.
append
(
program
)
return
certificate_programs
return
certificate_programs
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