コード例 #1
0
    def test_update_and_retrieve_preference_info_unicode(self):
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)

        profile_api.update_preferences(self.USERNAME, **{u'ⓟⓡⓔⓕⓔⓡⓔⓝⓒⓔ_ⓚⓔⓨ': u'ǝnןɐʌ_ǝɔuǝɹǝɟǝɹd'})

        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences[u'ⓟⓡⓔⓕⓔⓡⓔⓝⓒⓔ_ⓚⓔⓨ'], u'ǝnןɐʌ_ǝɔuǝɹǝɟǝɹd')
コード例 #2
0
ファイル: views.py プロジェクト: SPECUSA/edx-platform
def index(request):
    """Render the profile info page.

    Args:
        request (HttpRequest)

    Returns:
        HttpResponse: 200 if successful
        HttpResponse: 302 if not logged in (redirect to login page)
        HttpResponse: 405 if using an unsupported HTTP method

    Example:

        GET /profile

    """
    user = request.user

    released_languages = language_api.released_languages()

    preferred_language_code = profile_api.preference_info(user.username).get(LANGUAGE_KEY)
    preferred_language = language_api.preferred_language(preferred_language_code)

    context = {
        'disable_courseware_js': True,
        'released_languages': released_languages,
        'preferred_language': preferred_language,
    }

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH'):
        context['provider_user_states'] = pipeline.get_provider_user_states(user)

    return render_to_response('student_profile/index.html', context)
コード例 #3
0
    def test_update_and_retrieve_preference_info(self):
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)

        profile_api.update_preferences(self.USERNAME, preference_key='preference_value')

        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences['preference_key'], 'preference_value')
コード例 #4
0
def language_info(request):
    """Retrieve information about languages.

    Gets the user's preferred language and the list of released
    languages, encoding the information as JSON.

    Args:
        request (HttpRequest)

    Returns:
        HttpResponse: 200 if successful on GET
        HttpResponse: 302 if not logged in (redirect to login page)
        HttpResponse: 405 if using an unsupported HTTP method
        HttpResponse: 500 if an unexpected error occurs

    Example:

        GET /profile/preferences/languages

    """
    user = request.user

    preferred_language_code = profile_api.preference_info(user.username).get(LANGUAGE_KEY)
    preferred_language = language_api.preferred_language(preferred_language_code)
    response_data = {'preferredLanguage': {'code': preferred_language.code, 'name': preferred_language.name}}

    languages = language_api.released_languages()
    response_data['languages'] = [{'code': language.code, 'name': language.name} for language in languages]

    return HttpResponse(json.dumps(response_data), content_type='application/json')
コード例 #5
0
ファイル: views.py プロジェクト: OmarIthawi/edx-platform
def language_info(request):
    """Retrieve information about languages.

    Gets the user's preferred language and the list of released
    languages, encoding the information as JSON.

    Args:
        request (HttpRequest)

    Returns:
        HttpResponse: 200 if successful on GET
        HttpResponse: 302 if not logged in (redirect to login page)
        HttpResponse: 405 if using an unsupported HTTP method
        HttpResponse: 500 if an unexpected error occurs

    Example:

        GET /profile/preferences/languages

    """
    user = request.user

    preferred_language_code = profile_api.preference_info(user.username).get(LANGUAGE_KEY)
    preferred_language = language_api.preferred_language(preferred_language_code)
    response_data = {'preferredLanguage': {'code': preferred_language.code, 'name': preferred_language.name}}

    languages = language_api.released_languages()
    response_data['languages'] = [{'code': language.code, 'name': language.name} for language in languages]

    return HttpResponse(json.dumps(response_data), content_type='application/json')
コード例 #6
0
    def test_update_and_retrieve_preference_info(self):
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)

        profile_api.update_preferences(self.USERNAME,
                                       preference_key='preference_value')

        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences['preference_key'], 'preference_value')
コード例 #7
0
    def test_update_and_retrieve_preference_info_unicode(self):
        account_api.create_account(self.USERNAME, self.PASSWORD, self.EMAIL)

        profile_api.update_preferences(
            self.USERNAME, **{u'ⓟⓡⓔⓕⓔⓡⓔⓝⓒⓔ_ⓚⓔⓨ': u'ǝnןɐʌ_ǝɔuǝɹǝɟǝɹd'})

        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences[u'ⓟⓡⓔⓕⓔⓡⓔⓝⓒⓔ_ⓚⓔⓨ'], u'ǝnןɐʌ_ǝɔuǝɹǝɟǝɹd')
コード例 #8
0
ファイル: test_views.py プロジェクト: sambapete/edx-platform
    def test_language_change(self, mock_released_languages):
        mock_released_languages.return_value = [self.NEW_LANGUAGE]

        # Set French as the user's preferred language
        response = self._change_language(self.NEW_LANGUAGE.code)
        self.assertEqual(response.status_code, 204)

        # Verify that French is now the user's preferred language
        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences[LANGUAGE_KEY], self.NEW_LANGUAGE.code)

        # Verify that the page reloads in French
        response = self.client.get(reverse('profile_index'))
        self.assertContains(response, "Merci de choisir la langue")
コード例 #9
0
    def test_language_change(self, mock_released_languages):
        mock_released_languages.return_value = [self.TEST_LANGUAGE]

        # Set the dummy language as the user's preferred language
        response = self._change_preferences(language=self.TEST_LANGUAGE.code)
        self.assertEqual(response.status_code, 204)

        # Verify that the dummy language is now the user's preferred language
        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences[LANGUAGE_KEY], self.TEST_LANGUAGE.code)

        # Verify that the page reloads in the dummy language
        response = self.client.get(reverse('profile_index'))
        self.assertContains(response, u"Stüdént Pröfïlé")
コード例 #10
0
ファイル: test_views.py プロジェクト: OmarIthawi/edx-platform
    def test_language_change(self, mock_released_languages):
        mock_released_languages.return_value = [self.TEST_LANGUAGE]

        # Set the dummy language as the user's preferred language
        response = self._change_preferences(language=self.TEST_LANGUAGE.code)
        self.assertEqual(response.status_code, 204)

        # Verify that the dummy language is now the user's preferred language
        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences[LANGUAGE_KEY], self.TEST_LANGUAGE.code)

        # Verify that the page reloads in the dummy language
        response = self.client.get(reverse('profile_index'))
        self.assertContains(response, u"Stüdént Pröfïlé")
コード例 #11
0
ファイル: views.py プロジェクト: sambapete/edx-platform
def index(request):
    """Render the profile info page.

    Args:
        request (HttpRequest)

    Returns:
        HttpResponse: 200 if successful
        HttpResponse: 302 if not logged in (redirect to login page)
        HttpResponse: 405 if using an unsupported HTTP method

    Example:

        GET /profile

    """
    user = request.user

    released_languages = language_api.released_languages()

    preferred_language_code = profile_api.preference_info(
        user.username).get(LANGUAGE_KEY)
    preferred_language = language_api.preferred_language(
        preferred_language_code)

    context = {
        'disable_courseware_js': True,
        'released_languages': released_languages,
        'preferred_language': preferred_language,
    }

    if settings.FEATURES.get('ENABLE_THIRD_PARTY_AUTH'):
        context['provider_user_states'] = pipeline.get_provider_user_states(
            user)

    return render_to_response('student_profile/index.html', context)
コード例 #12
0
    def test_retrieve_and_update_preference_info_no_user(self):
        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences, {})

        profile_api.update_preferences(self.USERNAME, preference_key='preference_value')
コード例 #13
0
    def test_retrieve_and_update_preference_info_no_user(self):
        preferences = profile_api.preference_info(self.USERNAME)
        self.assertEqual(preferences, {})

        profile_api.update_preferences(self.USERNAME,
                                       preference_key='preference_value')