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
a1f181e7
Commit
a1f181e7
authored
Jun 18, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the variable and method names clearer
parent
085a590b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
8 deletions
+12
-8
common/lib/xmodule/xmodule/course_module.py
+3
-3
common/lib/xmodule/xmodule/fields.py
+5
-4
common/lib/xmodule/xmodule/tests/test_fields.py
+4
-1
No files found.
common/lib/xmodule/xmodule/course_module.py
View file @
a1f181e7
...
@@ -672,10 +672,10 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
...
@@ -672,10 +672,10 @@ class CourseDescriptor(CourseFields, SequenceDescriptor):
@property
@property
def
forum_posts_allowed
(
self
):
def
forum_posts_allowed
(
self
):
date
standin
=
Date
()
date
_proxy
=
Date
()
try
:
try
:
blackout_periods
=
[(
date
standin
.
from_json
(
start
),
blackout_periods
=
[(
date
_proxy
.
from_json
(
start
),
date
standin
.
from_json
(
end
))
date
_proxy
.
from_json
(
end
))
for
start
,
end
for
start
,
end
in
self
.
discussion_blackouts
]
in
self
.
discussion_blackouts
]
now
=
datetime
.
now
(
UTC
())
now
=
datetime
.
now
(
UTC
())
...
...
common/lib/xmodule/xmodule/fields.py
View file @
a1f181e7
...
@@ -17,8 +17,9 @@ class Date(ModelType):
...
@@ -17,8 +17,9 @@ class Date(ModelType):
'''
'''
# See note below about not defaulting these
# See note below about not defaulting these
CURRENT_YEAR
=
datetime
.
datetime
.
now
(
UTC
)
.
year
CURRENT_YEAR
=
datetime
.
datetime
.
now
(
UTC
)
.
year
DEFAULT_DATE0
=
datetime
.
datetime
(
CURRENT_YEAR
,
1
,
1
,
tzinfo
=
UTC
)
PREVENT_DEFAULT_DAY_MON_SEED1
=
datetime
.
datetime
(
CURRENT_YEAR
,
1
,
1
,
tzinfo
=
UTC
)
DEFAULT_DATE1
=
datetime
.
datetime
(
CURRENT_YEAR
,
2
,
2
,
tzinfo
=
UTC
)
PREVENT_DEFAULT_DAY_MON_SEED2
=
datetime
.
datetime
(
CURRENT_YEAR
,
2
,
2
,
tzinfo
=
UTC
)
def
_parse_date_wo_default_month_day
(
self
,
field
):
def
_parse_date_wo_default_month_day
(
self
,
field
):
"""
"""
Parse the field as an iso string but prevent dateutils from defaulting the day or month while
Parse the field as an iso string but prevent dateutils from defaulting the day or month while
...
@@ -27,8 +28,8 @@ class Date(ModelType):
...
@@ -27,8 +28,8 @@ class Date(ModelType):
# It's not trivial to replace dateutil b/c parsing timezones as Z, +03:30, -400 is hard in python
# It's not trivial to replace dateutil b/c parsing timezones as Z, +03:30, -400 is hard in python
# however, we don't want dateutil to default the month or day (but some tests at least expect
# however, we don't want dateutil to default the month or day (but some tests at least expect
# us to default year); so, we'll see if dateutil uses the defaults for these the hard way
# us to default year); so, we'll see if dateutil uses the defaults for these the hard way
result
=
dateutil
.
parser
.
parse
(
field
,
default
=
self
.
DEFAULT_DATE0
)
result
=
dateutil
.
parser
.
parse
(
field
,
default
=
self
.
PREVENT_DEFAULT_DAY_MON_SEED1
)
result_other
=
dateutil
.
parser
.
parse
(
field
,
default
=
self
.
DEFAULT_DATE
1
)
result_other
=
dateutil
.
parser
.
parse
(
field
,
default
=
self
.
PREVENT_DEFAULT_DAY_MON_SEED
1
)
if
result
!=
result_other
:
if
result
!=
result_other
:
log
.
warning
(
"Field {0} is missing month or day"
.
format
(
self
.
_name
,
field
))
log
.
warning
(
"Field {0} is missing month or day"
.
format
(
self
.
_name
,
field
))
return
None
return
None
...
...
common/lib/xmodule/xmodule/tests/test_fields.py
View file @
a1f181e7
...
@@ -56,7 +56,10 @@ class DateTest(unittest.TestCase):
...
@@ -56,7 +56,10 @@ class DateTest(unittest.TestCase):
DateTest
.
date
.
from_json
(
"December 4 16:30"
))
DateTest
.
date
.
from_json
(
"December 4 16:30"
))
self
.
assertIsNone
(
DateTest
.
date
.
from_json
(
"12 12:00"
))
self
.
assertIsNone
(
DateTest
.
date
.
from_json
(
"12 12:00"
))
def
test_odd_from_json
(
self
):
def
test_non_std_from_json
(
self
):
"""
Test the non-standard args being passed to from_json
"""
now
=
datetime
.
datetime
.
now
(
UTC
())
now
=
datetime
.
datetime
.
now
(
UTC
())
delta
=
now
-
datetime
.
datetime
.
fromtimestamp
(
0
,
UTC
())
delta
=
now
-
datetime
.
datetime
.
fromtimestamp
(
0
,
UTC
())
self
.
assertEqual
(
DateTest
.
date
.
from_json
(
delta
.
total_seconds
()
*
1000
),
self
.
assertEqual
(
DateTest
.
date
.
from_json
(
delta
.
total_seconds
()
*
1000
),
...
...
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