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


Python Bundle.data['course_id']方法代码示例

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


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

示例1: _staff_or_instructor_delete_list

# 需要导入模块: from tastypie.bundle import Bundle [as 别名]
# 或者: from tastypie.bundle.Bundle import data['course_id'] [as 别名]
    def _staff_or_instructor_delete_list(self, request, **kwargs):

        # ETAPA 1 - Desserialização e validação dos dados recebidos
        # ---------------------------------------------------------

        course_id = course_id_decoder(kwargs['pk'])
        staff_or_instructor = kwargs['staff_or_instructor']
        deserialized = self.deserialize(request, request.body, 
            format=request.META.get('CONTENT_TYPE', 'application/json'))
        deserialized = self.alter_deserialized_detail_data(
            request, deserialized)
        bundle = Bundle(data=dict_strip_unicode_keys(deserialized), 
            request=request)
        
        if 'user_resource_uri' in bundle.data:  
            user_resource_uri = bundle.data['user_resource_uri']
        bundle.data['course_id'] = course_id
        bundle.data['staff_or_instructor'] = kwargs['staff_or_instructor']

        validation = CleanedDataFormValidation(form_class=CourseDeleteUserForm)
        validation_errors = validation.is_valid(bundle)
        
        if validation_errors:
            raise ImmediateHttpResponse(response=self.error_response(
                bundle.request, validation_errors))

        # ETAPA 2 - Efetuando operações no EDX
        # ------------------------------------

        username = user_resource_uri.split('/')[-2:-1][0]
        course_remove_user(course_id, username, staff_or_instructor)
        return http.HttpNoContent()
开发者ID:wwagner33,项目名称:django-solaredx,代码行数:34,代码来源:api_v1.py

示例2: delete_detail

# 需要导入模块: from tastypie.bundle import Bundle [as 别名]
# 或者: from tastypie.bundle.Bundle import data['course_id'] [as 别名]
    def delete_detail(self, request, **kwargs):
        " Deleta um curso. "

        # ETAPA 1 - Desserialização e validação dos dados recebidos
        # ---------------------------------------------------------

        course_id = course_id_decoder(kwargs['course_id_solaredx'])
        deserialized = self.deserialize(request, request.body, 
            format=request.META.get('CONTENT_TYPE', 'application/json'))
        deserialized = self.alter_deserialized_detail_data(
            request, deserialized)
        bundle = Bundle(data=dict_strip_unicode_keys(deserialized), 
            request=request)
        bundle.data['course_id'] = course_id
        validation = CleanedDataFormValidation(form_class=CourseDeleteForm)
        validation_errors = validation.is_valid(bundle)

        if validation_errors:
            raise ImmediateHttpResponse(response=self.error_response(
                bundle.request, validation_errors))        

        # ETAPA 2 - Efetuando operações no EDX
        # ------------------------------------

        course_delete(course_id)
        return http.HttpNoContent()
开发者ID:wwagner33,项目名称:django-solaredx,代码行数:28,代码来源:api_v1.py


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