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
7dc68f6e
Commit
7dc68f6e
authored
May 12, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xblock-fields: Revert "Enforce type of the XBlocks Fields when set"
This reverts commit
e08b9898
.
parent
39154d24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
32 deletions
+5
-32
cms/lib/xblock/mixin.py
+0
-10
common/lib/xmodule/xmodule/fields.py
+4
-21
requirements/edx/github.txt
+1
-1
No files found.
cms/lib/xblock/mixin.py
View file @
7dc68f6e
...
...
@@ -3,7 +3,6 @@ Mixin defining common Studio functionality
"""
import
datetime
import
time
from
xblock.fields
import
Scope
,
Field
,
Integer
,
XBlockMixin
...
...
@@ -21,15 +20,6 @@ class DateTuple(Field):
return
list
(
value
.
timetuple
())
def
enforce_type
(
self
,
value
):
if
isinstance
(
value
,
datetime
.
datetime
)
or
value
is
None
:
return
value
if
isinstance
(
value
,
tuple
,
time
.
struct_time
):
return
self
.
from_json
(
DateTuple
)
raise
TypeError
(
"Value should be datetime, a timetuple or None, not {}"
.
format
(
type
(
value
)))
class
CmsBlockMixin
(
XBlockMixin
):
"""
...
...
common/lib/xmodule/xmodule/fields.py
View file @
7dc68f6e
...
...
@@ -68,7 +68,10 @@ class Date(Field):
"""
if
value
is
None
:
return
None
if
isinstance
(
value
,
datetime
.
datetime
):
if
isinstance
(
value
,
time
.
struct_time
):
# struct_times are always utc
return
time
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
,
value
)
elif
isinstance
(
value
,
datetime
.
datetime
):
if
value
.
tzinfo
is
None
or
value
.
utcoffset
()
.
total_seconds
()
==
0
:
# isoformat adds +00:00 rather than Z
return
value
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
SZ'
)
...
...
@@ -77,8 +80,6 @@ class Date(Field):
else
:
raise
TypeError
(
"Cannot convert {!r} to json"
.
format
(
value
))
enforce_type
=
from_json
TIMEDELTA_REGEX
=
re
.
compile
(
r'^((?P<days>\d+?) day(?:s?))?(\s)?((?P<hours>\d+?) hour(?:s?))?(\s)?((?P<minutes>\d+?) minute(?:s)?)?(\s)?((?P<seconds>\d+?) second(?:s)?)?$'
)
...
...
@@ -116,15 +117,6 @@ class Timedelta(Field):
values
.
append
(
"
%
d
%
s"
%
(
cur_value
,
attr
))
return
' '
.
join
(
values
)
def
enforce_type
(
self
,
value
):
"""
Ensure that when set explicitly the Field is set to a timedelta
"""
if
isinstance
(
value
,
datetime
.
timedelta
)
or
value
is
None
:
return
value
return
self
.
from_json
(
value
)
class
RelativeTime
(
Field
):
"""
...
...
@@ -227,12 +219,3 @@ class RelativeTime(Field):
if
len
(
stringified
)
==
7
:
stringified
=
'0'
+
stringified
return
stringified
def
enforce_type
(
self
,
value
):
"""
Ensure that when set explicitly the Field is set to a timedelta
"""
if
isinstance
(
value
,
datetime
.
timedelta
)
or
value
is
None
:
return
None
return
self
.
from_json
(
value
)
requirements/edx/github.txt
View file @
7dc68f6e
...
...
@@ -17,7 +17,7 @@
-e git+https://github.com/appliedsec/pygeoip.git@95e69341cebf5a6a9fbf7c4f5439d458898bdc3b#egg=pygeoip
# Our libraries:
-e git+https://github.com/edx
-solutions/XBlock.git@2821f89f844f644c2091fa50bba06eb209b8f127
#egg=XBlock
-e git+https://github.com/edx
/XBlock.git@cfe5c37f98febd9a215d23cb206a25711056a142
#egg=XBlock
-e git+https://github.com/edx/codejail.git@71f5c5616e2a73ae8cecd1ff2362774a773d3665#egg=codejail
-e git+https://github.com/edx/diff-cover.git@v0.2.9#egg=diff_cover
-e git+https://github.com/edx/js-test-tool.git@v0.1.5#egg=js_test_tool
...
...
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