Merge pull request #1152 from MITx/feature/dhm/cms-settings
Don't save null about items to db as it chokes lms.
This commit is contained in:
@@ -116,3 +116,12 @@ def compute_unit_state(unit):
|
||||
|
||||
def get_date_display(date):
|
||||
return date.strftime("%d %B, %Y at %I:%M %p")
|
||||
|
||||
def update_item(location, value):
|
||||
"""
|
||||
If value is None, delete the db entry. Otherwise, update it using the correct modulestore.
|
||||
"""
|
||||
if value is None:
|
||||
get_modulestore(location).delete_item(location)
|
||||
else:
|
||||
get_modulestore(location).update_item(location, value)
|
||||
@@ -7,6 +7,7 @@ import time
|
||||
from contentstore.utils import get_modulestore
|
||||
from util.converters import jsdate_to_time, time_to_date
|
||||
from cms.djangoapps.models.settings import course_grading
|
||||
from cms.djangoapps.contentstore.utils import update_item
|
||||
|
||||
class CourseDetails:
|
||||
def __init__(self, location):
|
||||
@@ -117,16 +118,16 @@ class CourseDetails:
|
||||
# NOTE: below auto writes to the db w/o verifying that any of the fields actually changed
|
||||
# to make faster, could compare against db or could have client send over a list of which fields changed.
|
||||
temploc = Location(course_location)._replace(category='about', name='syllabus')
|
||||
get_modulestore(temploc).update_item(temploc, jsondict['syllabus'])
|
||||
update_item(temploc, jsondict['syllabus'])
|
||||
|
||||
temploc = temploc._replace(name='overview')
|
||||
get_modulestore(temploc).update_item(temploc, jsondict['overview'])
|
||||
update_item(temploc, jsondict['overview'])
|
||||
|
||||
temploc = temploc._replace(name='effort')
|
||||
get_modulestore(temploc).update_item(temploc, jsondict['effort'])
|
||||
update_item(temploc, jsondict['effort'])
|
||||
|
||||
temploc = temploc._replace(name='video')
|
||||
get_modulestore(temploc).update_item(temploc, jsondict['intro_video'])
|
||||
update_item(temploc, jsondict['intro_video'])
|
||||
|
||||
|
||||
# Could just generate and return a course obj w/o doing any db reads, but I put the reads in as a means to confirm
|
||||
|
||||
Reference in New Issue
Block a user