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
a653d449
Commit
a653d449
authored
Jul 19, 2016
by
Renzo Lucioni
Committed by
GitHub
Jul 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13024 from edx/renzo/pdp-enrollment-start
Prevent program utilities from formatting dates prior to 1900
parents
2a2a1c3c
7ede26a1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletions
+20
-1
openedx/core/djangoapps/programs/tests/test_utils.py
+16
-0
openedx/core/djangoapps/programs/utils.py
+4
-1
No files found.
openedx/core/djangoapps/programs/tests/test_utils.py
View file @
a653d449
...
...
@@ -820,6 +820,22 @@ class TestSupplementProgramData(ProgramsApiConfigMixin, ModuleStoreTestCase):
enrollment_open_date
=
enrollment_open_date
,
)
def
test_no_enrollment_start_date
(
self
):
"""Verify that a closed course with no explicit enrollment start date doesn't cause an error.
Regression test for ECOM-4973.
"""
self
.
course
.
enrollment_end
=
timezone
.
now
()
-
datetime
.
timedelta
(
days
=
1
)
self
.
course
=
self
.
update_course
(
self
.
course
,
self
.
user
.
id
)
# pylint: disable=no-member
data
=
utils
.
supplement_program_data
(
self
.
program
,
self
.
user
)
self
.
_assert_supplemented
(
data
,
is_enrollment_open
=
False
,
enrollment_open_date
=
strftime_localized
(
utils
.
DEFAULT_ENROLLMENT_START_DATE
,
'SHORT_DATE'
),
)
@ddt.data
(
True
,
False
)
@mock.patch
(
UTILS_MODULE
+
'.certificate_api.certificate_downloadable_status'
)
@mock.patch
(
CERTIFICATES_API_MODULE
+
'.has_html_certificates_enabled'
)
...
...
openedx/core/djangoapps/programs/utils.py
View file @
a653d449
...
...
@@ -25,6 +25,9 @@ from xmodule.course_metadata_utils import DEFAULT_START_DATE
log
=
logging
.
getLogger
(
__name__
)
# The datetime module's strftime() methods require a year >= 1900.
DEFAULT_ENROLLMENT_START_DATE
=
datetime
.
datetime
(
1900
,
1
,
1
,
tzinfo
=
pytz
.
UTC
)
def
get_programs
(
user
,
program_id
=
None
):
"""Given a user, get programs from the Programs service.
...
...
@@ -356,7 +359,7 @@ def supplement_program_data(program_data, user):
is_enrolled
=
CourseEnrollment
.
is_enrolled
(
user
,
course_key
)
enrollment_start
=
course_overview
.
enrollment_start
or
datetime
.
datetime
.
min
.
replace
(
tzinfo
=
pytz
.
UTC
)
enrollment_start
=
course_overview
.
enrollment_start
or
DEFAULT_ENROLLMENT_START_DATE
enrollment_end
=
course_overview
.
enrollment_end
or
datetime
.
datetime
.
max
.
replace
(
tzinfo
=
pytz
.
UTC
)
is_enrollment_open
=
enrollment_start
<=
timezone
.
now
()
<
enrollment_end
...
...
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