'Update the course\'s default grace period. Incoming dict is {hours: h, minutes: m} possibly as a
grace_period entry in an enclosing dict. It is also safe to call this method with a value of
None for graceperiodjson.'

@staticmethod
def update_grace_period_from_json(course_key, graceperiodjson, user):

    descriptor = modulestore().get_course(course_key)
    if (graceperiodjson is not None):
        if ('grace_period' in graceperiodjson):
            graceperiodjson = graceperiodjson['grace_period']
        grace_timedelta = timedelta(**graceperiodjson)
        descriptor.graceperiod = grace_timedelta
        modulestore().update_item(descriptor, user.id)
