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


Python CourseEnrollmentAllowed.delete_by_user_value方法代码示例

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


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

示例1: post

# 需要导入模块: from student.models import CourseEnrollmentAllowed [as 别名]
# 或者: from student.models.CourseEnrollmentAllowed import delete_by_user_value [as 别名]
    def post(self, request):
        """
        POST /api/user/v1/accounts/retire/

        {
            'username': 'user_to_retire'
        }

        Retires the user with the given username.  This includes
        retiring this username, the associates email address, and
        any other PII associated with this user.
        """
        username = request.data['username']
        if is_username_retired(username):
            return Response(status=status.HTTP_404_NOT_FOUND)

        try:
            retirement_status = UserRetirementStatus.get_retirement_for_retirement_action(username)
            user = retirement_status.user
            retired_username = retirement_status.retired_username or get_retired_username_by_username(username)
            retired_email = retirement_status.retired_email or get_retired_email_by_email(user.email)
            original_email = retirement_status.original_email

            # Retire core user/profile information
            self.clear_pii_from_userprofile(user)
            self.delete_users_profile_images(user)
            self.delete_users_country_cache(user)

            # Retire data from Enterprise models
            self.retire_users_data_sharing_consent(username, retired_username)
            self.retire_sapsf_data_transmission(user)
            self.retire_user_from_pending_enterprise_customer_user(user, retired_email)
            self.retire_entitlement_support_detail(user)

            # Retire misc. models that may contain PII of this user
            SoftwareSecurePhotoVerification.retire_user(user.id)
            PendingEmailChange.delete_by_user_value(user, field='user')
            UserOrgTag.delete_by_user_value(user, field='user')

            # Retire any objects linked to the user via their original email
            CourseEnrollmentAllowed.delete_by_user_value(original_email, field='email')
            UnregisteredLearnerCohortAssignments.delete_by_user_value(original_email, field='email')

            # TODO: Password Reset links - https://openedx.atlassian.net/browse/PLAT-2104
            # TODO: Delete OAuth2 records - https://openedx.atlassian.net/browse/EDUCATOR-2703

            user.first_name = ''
            user.last_name = ''
            user.is_active = False
            user.username = retired_username
            user.save()
        except UserRetirementStatus.DoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except RetirementStateError as exc:
            return Response(text_type(exc), status=status.HTTP_400_BAD_REQUEST)
        except Exception as exc:  # pylint: disable=broad-except
            return Response(text_type(exc), status=status.HTTP_500_INTERNAL_SERVER_ERROR)

        return Response(status=status.HTTP_204_NO_CONTENT)
开发者ID:luisvasq,项目名称:edx-platform,代码行数:61,代码来源:views.py

示例2: post

# 需要导入模块: from student.models import CourseEnrollmentAllowed [as 别名]
# 或者: from student.models.CourseEnrollmentAllowed import delete_by_user_value [as 别名]
    def post(self, request):
        """
        POST /api/user/v1/accounts/retire/

        {
            'username': 'user_to_retire'
        }

        Retires the user with the given username.  This includes
        retiring this username, the associated email address, and
        any other PII associated with this user.
        """
        username = request.data['username']

        try:
            retirement_status = UserRetirementStatus.get_retirement_for_retirement_action(username)
            user = retirement_status.user
            retired_username = retirement_status.retired_username or get_retired_username_by_username(username)
            retired_email = retirement_status.retired_email or get_retired_email_by_email(user.email)
            original_email = retirement_status.original_email

            # Retire core user/profile information
            self.clear_pii_from_userprofile(user)
            self.delete_users_profile_images(user)
            self.delete_users_country_cache(user)

            # Retire data from Enterprise models
            self.retire_users_data_sharing_consent(username, retired_username)
            self.retire_sapsf_data_transmission(user)
            self.retire_degreed_data_transmission(user)
            self.retire_user_from_pending_enterprise_customer_user(user, retired_email)
            self.retire_entitlement_support_detail(user)

            # Retire misc. models that may contain PII of this user
            PendingEmailChange.delete_by_user_value(user, field='user')
            UserOrgTag.delete_by_user_value(user, field='user')

            # Retire any objects linked to the user via their original email
            CourseEnrollmentAllowed.delete_by_user_value(original_email, field='email')
            UnregisteredLearnerCohortAssignments.delete_by_user_value(original_email, field='email')

            # This signal allows code in higher points of LMS to retire the user as necessary
            USER_RETIRE_LMS_CRITICAL.send(sender=self.__class__, user=user)

            user.first_name = ''
            user.last_name = ''
            user.is_active = False
            user.username = retired_username
            user.save()
        except UserRetirementStatus.DoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except RetirementStateError as exc:
            return Response(text_type(exc), status=status.HTTP_400_BAD_REQUEST)
        except Exception as exc:  # pylint: disable=broad-except
            return Response(text_type(exc), status=status.HTTP_500_INTERNAL_SERVER_ERROR)

        return Response(status=status.HTTP_204_NO_CONTENT)
开发者ID:mreyk,项目名称:edx-platform,代码行数:59,代码来源:views.py

示例3: test_retiring_nonexistent_user_doesnt_modify_records

# 需要导入模块: from student.models import CourseEnrollmentAllowed [as 别名]
# 或者: from student.models.CourseEnrollmentAllowed import delete_by_user_value [as 别名]
 def test_retiring_nonexistent_user_doesnt_modify_records(self):
     is_successful = CourseEnrollmentAllowed.delete_by_user_value(
         value='[email protected]',
         field='email'
     )
     self.assertFalse(is_successful)
     user_search_results = CourseEnrollmentAllowed.objects.filter(
         email=self.email
     )
     self.assertTrue(user_search_results.exists())
开发者ID:appsembler,项目名称:edx-platform,代码行数:12,代码来源:test_models.py

示例4: test_retiring_user_deletes_record

# 需要导入模块: from student.models import CourseEnrollmentAllowed [as 别名]
# 或者: from student.models.CourseEnrollmentAllowed import delete_by_user_value [as 别名]
 def test_retiring_user_deletes_record(self):
     is_successful = CourseEnrollmentAllowed.delete_by_user_value(
         value=self.email,
         field='email'
     )
     self.assertTrue(is_successful)
     user_search_results = CourseEnrollmentAllowed.objects.filter(
         email=self.email
     )
     self.assertFalse(user_search_results)
开发者ID:appsembler,项目名称:edx-platform,代码行数:12,代码来源:test_models.py


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