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
28fd39f7
Commit
28fd39f7
authored
Sep 08, 2017
by
sanfordstudent
Committed by
GitHub
Sep 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15975 from edx/sstudent/EDUCATOR-1317
common function for cert display date
parents
e6f807b0
4f977fb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
lms/djangoapps/certificates/tests/test_webview_views.py
+4
-1
lms/djangoapps/certificates/views/webview.py
+2
-9
openedx/core/djangoapps/certificates/api.py
+14
-1
No files found.
lms/djangoapps/certificates/tests/test_webview_views.py
View file @
28fd39f7
...
...
@@ -39,6 +39,7 @@ from lms.djangoapps.badges.tests.factories import (
CourseCompleteImageConfigurationFactory
)
from
lms.djangoapps.grades.tests.utils
import
mock_passing_grade
from
openedx.core.djangoapps.certificates.config
import
waffle
from
openedx.core.lib.tests.assertions.events
import
assert_event_matches
from
student.roles
import
CourseStaffRole
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
...
...
@@ -819,7 +820,9 @@ class CertificatesViewsTests(CommonCertificatesTestCase):
expected_date
=
datetime
.
datetime
.
today
()
else
:
expected_date
=
self
.
course
.
certificate_available_date
response
=
self
.
client
.
get
(
test_url
)
with
waffle
.
waffle
()
.
override
(
waffle
.
SELF_PACED_ONLY
,
active
=
True
):
with
waffle
.
waffle
()
.
override
(
waffle
.
INSTRUCTOR_PACED_ONLY
,
active
=
True
):
response
=
self
.
client
.
get
(
test_url
)
date
=
'{month} {day}, {year}'
.
format
(
month
=
strftime_localized
(
expected_date
,
"
%
B"
),
day
=
expected_date
.
day
,
...
...
lms/djangoapps/certificates/views/webview.py
View file @
28fd39f7
...
...
@@ -41,6 +41,7 @@ from edxmako.shortcuts import render_to_response
from
edxmako.template
import
Template
from
openedx.core.djangoapps.site_configuration
import
helpers
as
configuration_helpers
from
openedx.core.lib.courses
import
course_image_url
from
openedx.core.djangoapps.certificates.api
import
display_date_for_certificate
from
student.models
import
LinkedInAddToProfileConfiguration
from
util
import
organizations_helpers
as
organization_api
from
util.date_utils
import
strftime_localized
...
...
@@ -100,15 +101,7 @@ def _update_certificate_context(context, user_certificate, platform_name):
# Translators: The format of the date includes the full name of the month
course
=
get_course_by_id
(
user_certificate
.
course_id
)
if
user_certificate
.
course_id
else
None
if
(
course
and
not
course
.
self_paced
and
course
.
certificate_available_date
and
course
.
certificate_available_date
<
datetime
.
now
(
pytz
.
UTC
)
):
date
=
course
.
certificate_available_date
else
:
date
=
user_certificate
.
modified_date
date
=
display_date_for_certificate
(
course
,
user_certificate
)
context
[
'certificate_date_issued'
]
=
_
(
'{month} {day}, {year}'
)
.
format
(
month
=
strftime_localized
(
date
,
"
%
B"
),
day
=
date
.
day
,
...
...
openedx/core/djangoapps/certificates/api.py
View file @
28fd39f7
"""
The public API for certificates.
"""
from
datetime
import
datetime
from
pytz
import
UTC
from
openedx.core.djangoapps.certificates.config
import
waffle
...
...
@@ -37,3 +38,15 @@ def _enabled_and_self_paced(course):
def
can_show_certificate_available_date_field
(
course
):
return
_enabled_and_self_paced
(
course
)
def
display_date_for_certificate
(
course
,
certificate
):
if
(
auto_certificate_generation_enabled_for_course
(
course
)
and
not
course
.
self_paced
and
course
.
certificate_available_date
and
course
.
certificate_available_date
<
datetime
.
now
(
UTC
)
):
return
course
.
certificate_available_date
return
certificate
.
modified_date
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