コード例 #1
0
ファイル: views.py プロジェクト: stvstnfrd/edx-platform
    def _requirements(self, display_steps, is_active):
        """Determine which requirements to show the user.

        For example, if the user needs to submit a photo
        verification, tell the user that she will need
        a photo ID and a webcam.

        Arguments:
            display_steps (list): The steps to display to the user.
            is_active (bool): If False, adds a requirement to activate the user account.

        Returns:
            dict: Keys are requirement names, values are booleans
                indicating whether to show the requirement.

        """
        all_requirements = {
            self.ACCOUNT_ACTIVATION_REQ: not is_active,
            self.PHOTO_ID_REQ: False,
            self.WEBCAM_REQ: False,
        }

        # Remove the account activation requirement if disabled via waffle
        if is_account_activation_requirement_disabled():
            all_requirements.pop(self.ACCOUNT_ACTIVATION_REQ)

        display_steps = set(step['name'] for step in display_steps)

        for step, step_requirements in self.STEP_REQUIREMENTS.iteritems():
            if step in display_steps:
                for requirement in step_requirements:
                    all_requirements[requirement] = True

        return all_requirements
コード例 #2
0
ファイル: views.py プロジェクト: haritshah33/edxplatform
    def _requirements(self, display_steps, is_active):
        """Determine which requirements to show the user.

        For example, if the user needs to submit a photo
        verification, tell the user that she will need
        a photo ID and a webcam.

        Arguments:
            display_steps (list): The steps to display to the user.
            is_active (bool): If False, adds a requirement to activate the user account.

        Returns:
            dict: Keys are requirement names, values are booleans
                indicating whether to show the requirement.

        """
        all_requirements = {
            self.ACCOUNT_ACTIVATION_REQ: not is_active,
            self.PHOTO_ID_REQ: False,
            self.WEBCAM_REQ: False,
        }

        # Remove the account activation requirement if disabled via waffle
        if is_account_activation_requirement_disabled():
            all_requirements.pop(self.ACCOUNT_ACTIVATION_REQ)

        display_steps = set(step['name'] for step in display_steps)

        for step, step_requirements in self.STEP_REQUIREMENTS.iteritems():
            if step in display_steps:
                for requirement in step_requirements:
                    all_requirements[requirement] = True

        return all_requirements
コード例 #3
0
 def has_permission(self, request, view):
     if not request.user.is_authenticated() and is_account_activation_requirement_disabled():
         try:
             request.user = User.objects.get(id=request.session._session_cache['_auth_user_id'])
         except DoesNotExist:
             pass
     return request.user.is_authenticated()
コード例 #4
0
ファイル: views.py プロジェクト: haritshah33/edxplatform
    def _get_user_active_status(self, user):
        """
        Returns the user's active status to the caller
        Overrides the actual value if account activation has been disabled via waffle switch

        Arguments:
            user (User): Current user involved in the onboarding/verification flow
        """
        return user.is_active or is_account_activation_requirement_disabled()
コード例 #5
0
ファイル: views.py プロジェクト: stvstnfrd/edx-platform
    def _get_user_active_status(self, user):
        """
        Returns the user's active status to the caller
        Overrides the actual value if account activation has been disabled via waffle switch

        Arguments:
            user (User): Current user involved in the onboarding/verification flow
        """
        return user.is_active or is_account_activation_requirement_disabled()
コード例 #6
0
 def has_permission(self, request, view):
     if not request.user.is_authenticated(
     ) and is_account_activation_requirement_disabled():
         try:
             request.user = User.objects.get(
                 id=request.session._session_cache['_auth_user_id'])
         except DoesNotExist:
             pass
     return request.user.is_authenticated()
コード例 #7
0
ファイル: views.py プロジェクト: eliesmr4/myedx
 def get(self, request, number):
     """ HTTP handler. """
     # If the account activation requirement is disabled for this installation, override the
     # anonymous user object attached to the request with the actual user object (if it exists)
     if not request.user.is_authenticated(
     ) and is_account_activation_requirement_disabled():
         try:
             request.user = User.objects.get(
                 id=request.session._session_cache['_auth_user_id'])
         except User.DoesNotExist:
             return JsonResponse(status=403)
     try:
         order = ecommerce_api_client(request.user).orders(number).get()
         return JsonResponse(order)
     except exceptions.HttpNotFoundError:
         return JsonResponse(status=404)