Merge pull request #2094 from edx/db/change-section-start-date
Set default section start date to Jan 1, 2030
This commit is contained in:
@@ -164,9 +164,7 @@ class CourseFields(object):
|
||||
enrollment_start = Date(help="Date that enrollment for this class is opened", scope=Scope.settings)
|
||||
enrollment_end = Date(help="Date that enrollment for this class is closed", scope=Scope.settings)
|
||||
start = Date(help="Start time when this module is visible",
|
||||
# using now(UTC()) resulted in fractional seconds which screwed up comparisons and anyway w/b the
|
||||
# time of first invocation of this stmt on the server
|
||||
default=datetime.fromtimestamp(0, UTC()),
|
||||
default=datetime(2030, 1, 1, tzinfo=UTC()),
|
||||
scope=Scope.settings)
|
||||
end = Date(help="Date that this class ends", scope=Scope.settings)
|
||||
advertised_start = String(help="Date that this course is advertised to start", scope=Scope.settings)
|
||||
|
||||
@@ -17,7 +17,7 @@ class InheritanceMixin(XBlockMixin):
|
||||
|
||||
start = Date(
|
||||
help="Start time when this module is visible",
|
||||
default=datetime.fromtimestamp(0, UTC),
|
||||
default=datetime(2030, 1, 1, tzinfo=UTC),
|
||||
scope=Scope.settings
|
||||
)
|
||||
due = Date(help="Date that this problem is due by", scope=Scope.settings)
|
||||
|
||||
@@ -55,8 +55,6 @@ class CourseFactory(XModuleFactory):
|
||||
# Write the data to the mongo datastore
|
||||
new_course = store.create_xmodule(location, metadata=kwargs.get('metadata', None))
|
||||
|
||||
new_course.start = datetime.datetime.now(UTC).replace(microsecond=0)
|
||||
|
||||
# The rest of kwargs become attributes on the course:
|
||||
for k, v in kwargs.iteritems():
|
||||
setattr(new_course, k, v)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
from fs.memoryfs import MemoryFS
|
||||
|
||||
@@ -13,7 +13,15 @@ from django.utils.timezone import UTC
|
||||
ORG = 'test_org'
|
||||
COURSE = 'test_course'
|
||||
|
||||
NOW = datetime.datetime.strptime('2013-01-01T01:00:00', '%Y-%m-%dT%H:%M:00').replace(tzinfo=UTC())
|
||||
NOW = datetime.strptime('2013-01-01T01:00:00', '%Y-%m-%dT%H:%M:00').replace(tzinfo=UTC())
|
||||
|
||||
|
||||
class CourseFieldsTestCase(unittest.TestCase):
|
||||
def test_default_start_date(self):
|
||||
self.assertEqual(
|
||||
xmodule.course_module.CourseFields.start.default,
|
||||
datetime(2030, 1, 1, tzinfo=UTC())
|
||||
)
|
||||
|
||||
|
||||
class DummySystem(ImportSystem):
|
||||
@@ -77,7 +85,7 @@ class IsNewCourseTestCase(unittest.TestCase):
|
||||
# Needed for test_is_newish
|
||||
datetime_patcher = patch.object(
|
||||
xmodule.course_module, 'datetime',
|
||||
Mock(wraps=datetime.datetime)
|
||||
Mock(wraps=datetime)
|
||||
)
|
||||
mocked_datetime = datetime_patcher.start()
|
||||
mocked_datetime.now.return_value = NOW
|
||||
|
||||
@@ -228,9 +228,11 @@ class ImportTestCase(BaseCourseTestCase):
|
||||
# Check that the child does not inherit a value for due
|
||||
child = descriptor.get_children()[0]
|
||||
self.assertEqual(child.due, None)
|
||||
|
||||
# Check that the child hasn't started yet
|
||||
self.assertLessEqual(
|
||||
child.start,
|
||||
datetime.datetime.now(UTC())
|
||||
datetime.datetime.now(UTC()),
|
||||
child.start
|
||||
)
|
||||
|
||||
def test_metadata_override_default(self):
|
||||
|
||||
Reference in New Issue
Block a user