当前位置: 首页>>代码示例>>Python>>正文


Python CourseDetails.update_from_json方法代码示例

本文整理汇总了Python中models.settings.course_details.CourseDetails.update_from_json方法的典型用法代码示例。如果您正苦于以下问题:Python CourseDetails.update_from_json方法的具体用法?Python CourseDetails.update_from_json怎么用?Python CourseDetails.update_from_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.settings.course_details.CourseDetails的用法示例。


在下文中一共展示了CourseDetails.update_from_json方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_and_fetch

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
 def test_update_and_fetch(self):
     jsondetails = CourseDetails.fetch(self.course.location)
     jsondetails.syllabus = "<a href='foo'>bar</a>"
     # encode - decode to convert date fields and other data which changes form
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).syllabus,
         jsondetails.syllabus, "After set syllabus"
     )
     jsondetails.overview = "Overview"
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).overview,
         jsondetails.overview, "After set overview"
     )
     jsondetails.intro_video = "intro_video"
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).intro_video,
         jsondetails.intro_video, "After set intro_video"
     )
     jsondetails.effort = "effort"
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).effort,
         jsondetails.effort, "After set effort"
     )
     jsondetails.start_date = datetime.datetime(2010, 10, 1, 0, tzinfo=UTC())
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).start_date,
         jsondetails.start_date
     )
开发者ID:Mtax,项目名称:MHST2013-14,代码行数:30,代码来源:test_course_settings.py

示例2: test_update_and_fetch

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
 def test_update_and_fetch(self):
     # # NOTE: I couldn't figure out how to validly test time setting w/ all the conversions
     jsondetails = CourseDetails.fetch(self.course_location)
     jsondetails.syllabus = "<a href='foo'>bar</a>"
     # encode - decode to convert date fields and other data which changes
     # form
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).syllabus,
         jsondetails.syllabus, "After set syllabus"
     )
     jsondetails.overview = "Overview"
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).overview,
         jsondetails.overview, "After set overview"
     )
     jsondetails.intro_video = "intro_video"
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).intro_video,
         jsondetails.intro_video, "After set intro_video"
     )
     jsondetails.effort = "effort"
     self.assertEqual(
         CourseDetails.update_from_json(jsondetails.__dict__).effort,
         jsondetails.effort, "After set effort"
     )
开发者ID:hughdbrown,项目名称:edx-platform,代码行数:27,代码来源:test_course_settings.py

示例3: settings_handler

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
def settings_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
    """
    Course settings for dates and about pages
    GET
        html: get the page
        json: get the CourseDetails model
    PUT
        json: update the Course and About xblocks through the CourseDetails model
    """
    locator, course_module = _get_locator_and_course(course_id, branch, version_guid, block, request.user)
    if "text/html" in request.META.get("HTTP_ACCEPT", "") and request.method == "GET":
        upload_asset_url = locator.url_reverse("assets/")

        return render_to_response(
            "settings.html",
            {
                "context_course": course_module,
                "course_locator": locator,
                "lms_link_for_about_page": utils.get_lms_link_for_about_page(course_module.location),
                "course_image_url": utils.course_image_url(course_module),
                "details_url": locator.url_reverse("/settings/details/"),
                "about_page_editable": not settings.FEATURES.get("ENABLE_MKTG_SITE", False),
                "upload_asset_url": upload_asset_url,
            },
        )
    elif "application/json" in request.META.get("HTTP_ACCEPT", ""):
        if request.method == "GET":
            return JsonResponse(
                CourseDetails.fetch(locator),
                # encoder serializes dates, old locations, and instances
                encoder=CourseSettingsEncoder,
            )
        else:  # post or put, doesn't matter.
            return JsonResponse(CourseDetails.update_from_json(locator, request.json), encoder=CourseSettingsEncoder)
开发者ID:nikileshsa,项目名称:edx-platform,代码行数:36,代码来源:course.py

示例4: settings_handler

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
def settings_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
    """
    Course settings for dates and about pages
    GET
        html: get the page
        json: get the CourseDetails model
    PUT
        json: update the Course and About xblocks through the CourseDetails model
    """
    locator, course_module = _get_locator_and_course(
        package_id, branch, version_guid, block, request.user
    )
    if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
        upload_asset_url = locator.url_reverse('assets/')

        # see if the ORG of this course can be attributed to a 'Microsite'. In that case, the
        # course about page should be editable in Studio
        about_page_editable = not MicrositeConfiguration.get_microsite_configuration_value_for_org(
            course_module.location.org,
            'ENABLE_MKTG_SITE',
            settings.FEATURES.get('ENABLE_MKTG_SITE', False)
        )

        short_description_editable = settings.FEATURES.get('EDITABLE_SHORT_DESCRIPTION', True)

        return render_to_response('settings.html', {
            'context_course': course_module,
            'course_locator': locator,
            'lms_link_for_about_page': utils.get_lms_link_for_about_page(course_module.location),
            'course_image_url': utils.course_image_url(course_module),
            'details_url': locator.url_reverse('/settings/details/'),
            'about_page_editable': about_page_editable,
            'short_description_editable': short_description_editable,
            'upload_asset_url': upload_asset_url
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(
                CourseDetails.fetch(locator),
                # encoder serializes dates, old locations, and instances
                encoder=CourseSettingsEncoder
            )
        else:  # post or put, doesn't matter.
            return JsonResponse(
                CourseDetails.update_from_json(locator, request.json, request.user),
                encoder=CourseSettingsEncoder
            )
开发者ID:robertlight,项目名称:edx-platform,代码行数:49,代码来源:course.py

示例5: settings_handler

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
def settings_handler(request, course_key_string):
    """
    Course settings for dates and about pages
    GET
        html: get the page
        json: get the CourseDetails model
    PUT
        json: update the Course and About xblocks through the CourseDetails model
    """
    course_key = CourseKey.from_string(course_key_string)
    course_module = _get_course_module(course_key, request.user)
    if "text/html" in request.META.get("HTTP_ACCEPT", "") and request.method == "GET":
        upload_asset_url = reverse_course_url("assets_handler", course_key)

        # see if the ORG of this course can be attributed to a 'Microsite'. In that case, the
        # course about page should be editable in Studio
        about_page_editable = not microsite.get_value_for_org(
            course_module.location.org, "ENABLE_MKTG_SITE", settings.FEATURES.get("ENABLE_MKTG_SITE", False)
        )

        short_description_editable = settings.FEATURES.get("EDITABLE_SHORT_DESCRIPTION", True)

        return render_to_response(
            "settings.html",
            {
                "context_course": course_module,
                "course_locator": course_key,
                "lms_link_for_about_page": utils.get_lms_link_for_about_page(course_key),
                "course_image_url": utils.course_image_url(course_module),
                "details_url": reverse_course_url("settings_handler", course_key),
                "about_page_editable": about_page_editable,
                "short_description_editable": short_description_editable,
                "upload_asset_url": upload_asset_url,
            },
        )
    elif "application/json" in request.META.get("HTTP_ACCEPT", ""):
        if request.method == "GET":
            return JsonResponse(
                CourseDetails.fetch(course_key),
                # encoder serializes dates, old locations, and instances
                encoder=CourseSettingsEncoder,
            )
        else:  # post or put, doesn't matter.
            return JsonResponse(
                CourseDetails.update_from_json(course_key, request.json, request.user), encoder=CourseSettingsEncoder
            )
开发者ID:hmcmooc,项目名称:muddx-platform,代码行数:48,代码来源:course.py

示例6: test_update_and_fetch

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
 def test_update_and_fetch(self):
     jsondetails = CourseDetails.fetch(self.course.id)
     jsondetails.syllabus = "<a href='foo'>bar</a>"
     # encode - decode to convert date fields and other data which changes form
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).syllabus,
         jsondetails.syllabus, "After set syllabus"
     )
     jsondetails.short_description = "Short Description"
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).short_description,
         jsondetails.short_description, "After set short_description"
     )
     jsondetails.overview = "Overview"
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).overview,
         jsondetails.overview, "After set overview"
     )
     jsondetails.intro_video = "intro_video"
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).intro_video,
         jsondetails.intro_video, "After set intro_video"
     )
     jsondetails.effort = "effort"
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).effort,
         jsondetails.effort, "After set effort"
     )
     jsondetails.category = "category"
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).category,
         jsondetails.category, "After set category"
     )
     jsondetails.start_date = datetime.datetime(2010, 10, 1, 0, tzinfo=UTC())
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).start_date,
         jsondetails.start_date
     )
     jsondetails.course_image_name = "an_image.jpg"
     self.assertEqual(
         CourseDetails.update_from_json(self.course.id, jsondetails.__dict__, self.user).course_image_name,
         jsondetails.course_image_name
     )
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:45,代码来源:test_course_settings.py

示例7: settings_handler

# 需要导入模块: from models.settings.course_details import CourseDetails [as 别名]
# 或者: from models.settings.course_details.CourseDetails import update_from_json [as 别名]
def settings_handler(request, tag=None, course_id=None, branch=None, version_guid=None, block=None):
    """
    Course settings for dates and about pages
    GET
        html: get the page
        json: get the CourseDetails model
    PUT
        json: update the Course and About xblocks through the CourseDetails model
    """
    locator = BlockUsageLocator(course_id=course_id, branch=branch, version_guid=version_guid, usage_id=block)
    if not has_access(request.user, locator):
        raise PermissionDenied()

    if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
        course_old_location = loc_mapper().translate_locator_to_location(locator)
        course_module = modulestore().get_item(course_old_location)

        upload_asset_url = locator.url_reverse('assets/')

        return render_to_response('settings.html', {
            'context_course': course_module,
            'course_locator': locator,
            'lms_link_for_about_page': utils.get_lms_link_for_about_page(course_old_location),
            'course_image_url': utils.course_image_url(course_module),
            'details_url': locator.url_reverse('/settings/details/'),
            'about_page_editable': not settings.FEATURES.get(
                'ENABLE_MKTG_SITE', False
            ),
            'upload_asset_url': upload_asset_url
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(
                CourseDetails.fetch(locator),
                # encoder serializes dates, old locations, and instances
                encoder=CourseSettingsEncoder
            )
        else:  # post or put, doesn't matter.
            return JsonResponse(
                CourseDetails.update_from_json(locator, request.json),
                encoder=CourseSettingsEncoder
            )
开发者ID:e-ucm,项目名称:edx-platform,代码行数:44,代码来源:course.py


注:本文中的models.settings.course_details.CourseDetails.update_from_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。