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
394601f3
Commit
394601f3
authored
Jan 11, 2016
by
Tasawer
Committed by
Ahsan Ulhaq
Jan 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 'certificate_url' field for view certificate on learner dashboard.
ECOM-3281
parent
70eaf189
Hide 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 @
394601f3
...
...
@@ -41,7 +41,8 @@ class CredentialsDataMixin(object):
"program_id"
:
1
},
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-1"
"uuid"
:
"dummy-uuid-1"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-1/"
},
{
"id"
:
2
,
...
...
@@ -51,7 +52,8 @@ class CredentialsDataMixin(object):
"program_id"
:
2
},
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-2"
"uuid"
:
"dummy-uuid-2"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-2/"
},
{
"id"
:
3
,
...
...
@@ -61,7 +63,8 @@ class CredentialsDataMixin(object):
"program_id"
:
3
},
"status"
:
"revoked"
,
"uuid"
:
"dummy-uuid-3"
"uuid"
:
"dummy-uuid-3"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-3/"
},
{
"id"
:
4
,
...
...
@@ -72,7 +75,8 @@ class CredentialsDataMixin(object):
"certificate_type"
:
"honor"
},
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-4"
"uuid"
:
"dummy-uuid-4"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-4/"
},
{
"id"
:
5
,
...
...
@@ -83,7 +87,8 @@ class CredentialsDataMixin(object):
"certificate_type"
:
"verified"
},
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-5"
"uuid"
:
"dummy-uuid-5"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-5/"
},
{
"id"
:
6
,
...
...
@@ -94,7 +99,8 @@ class CredentialsDataMixin(object):
"certificate_type"
:
"honor"
},
"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):
"program_id"
:
7
},
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-7"
"uuid"
:
"dummy-uuid-7"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-7"
},
{
"id"
:
8
,
...
...
@@ -120,7 +127,8 @@ class CredentialsDataMixin(object):
"program_id"
:
8
},
"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 @
394601f3
...
...
@@ -80,7 +80,7 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
def
test_get_user_programs_credentials
(
self
):
"""Verify program credentials data can be retrieved and parsed correctly."""
# create credentials and program configuration
credentials_config
=
self
.
create_credentials_config
()
self
.
create_credentials_config
()
self
.
create_programs_config
()
# Mocking the API responses from programs and credentials
...
...
@@ -89,10 +89,6 @@ class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin
actual
=
get_user_program_credentials
(
self
.
user
)
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
self
.
assertEqual
(
len
(
actual
),
2
)
...
...
openedx/core/djangoapps/programs/tests/mixins.py
View file @
394601f3
...
...
@@ -57,6 +57,7 @@ class ProgramsDataMixin(object):
'category'
:
'xseries'
,
'status'
:
'unpublished'
,
'marketing_slug'
:
''
,
'credential_url'
:
'http://credentials.edx.org/credentials/dummy-uuid-1/'
,
'organizations'
:
[
{
'display_name'
:
'Test Organization A'
,
...
...
@@ -123,6 +124,7 @@ class ProgramsDataMixin(object):
'category'
:
'xseries'
,
'status'
:
'unpublished'
,
'marketing_slug'
:
''
,
'credential_url'
:
'http://credentials.edx.org/credentials/dummy-uuid-2/'
,
'organizations'
:
[
{
'display_name'
:
'Test Organization B'
,
...
...
@@ -194,7 +196,8 @@ class ProgramsDataMixin(object):
"program_id"
:
1
},
"status"
:
"awarded"
,
"uuid"
:
"dummy-uuid-1"
"uuid"
:
"dummy-uuid-1"
,
"certificate_url"
:
"http://credentials.edx.org/credentials/dummy-uuid-1/"
},
{
"id"
:
2
,
...
...
@@ -204,7 +207,8 @@ class ProgramsDataMixin(object):
"program_id"
:
2
},
"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 @
394601f3
...
...
@@ -137,15 +137,11 @@ class TestProgramRetrieval(ProgramsApiConfigMixin, ProgramsDataMixin,
def
test_get_program_for_certificates
(
self
):
"""Verify programs data can be retrieved and parsed correctly for certificates."""
self
.
create_programs_config
()
credentials_config
=
self
.
create_credentials_config
()
self
.
mock_programs_api
()
actual
=
get_programs_for_credentials
(
self
.
user
,
self
.
PROGRAMS_CREDENTIALS_DATA
)
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
(
actual
,
expected
)
...
...
openedx/core/djangoapps/programs/utils.py
View file @
394601f3
"""Helper functions for working with Programs."""
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.lib.edx_api_utils
import
get_edx_api_data
...
...
@@ -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
)
return
certificate_programs
credential_configuration
=
CredentialsApiConfig
.
current
()
for
program
in
programs
:
for
credential
in
programs_credentials
:
if
program
[
'id'
]
==
credential
[
'credential'
][
'program_id'
]:
credentials_url
=
'credentials/'
+
credential
[
'uuid'
]
program
[
'credential_url'
]
=
urljoin
(
credential_configuration
.
public_service_url
,
credentials_url
)
program
[
'credential_url'
]
=
credential
[
'certificate_url'
]
certificate_programs
.
append
(
program
)
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