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


Python UserPreference.set_preference方法代码示例

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


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

示例1: test_language_in_session

# 需要导入模块: from openedx.core.djangoapps.user_api.models import UserPreference [as 别名]
# 或者: from openedx.core.djangoapps.user_api.models.UserPreference import set_preference [as 别名]
    def test_language_in_session(self):
        # language set in both the user preferences and session,
        # session should get precedence
        self.request.session['django_language'] = 'en'
        UserPreference.set_preference(self.user, LANGUAGE_KEY, 'eo')
        self.middleware.process_request(self.request)

        self.assertEquals(self.request.session['django_language'], 'en')
开发者ID:JacobWay,项目名称:edx-platform,代码行数:10,代码来源:test_middleware.py

示例2: test_user_with_locale_claim

# 需要导入模块: from openedx.core.djangoapps.user_api.models import UserPreference [as 别名]
# 或者: from openedx.core.djangoapps.user_api.models.UserPreference import set_preference [as 别名]
    def test_user_with_locale_claim(self):
        language = "en"
        UserPreference.set_preference(self.user, LANGUAGE_KEY, language)
        scopes, claims = self.get_id_token_values("openid profile")

        self.assertIn("profile", scopes)

        locale = claims["locale"]
        self.assertEqual(language, locale)
开发者ID:akbargumbira,项目名称:Labster.EdX,代码行数:11,代码来源:tests.py

示例3: setUp

# 需要导入模块: from openedx.core.djangoapps.user_api.models import UserPreference [as 别名]
# 或者: from openedx.core.djangoapps.user_api.models.UserPreference import set_preference [as 别名]
    def setUp(self):
        # Platform language is English, instructor's language is Chinese,
        # student's language is French, so the emails should all be sent in
        # French.
        self.course = CourseFactory.create()
        self.instructor = InstructorFactory(course_key=self.course.id)
        UserPreference.set_preference(self.instructor, LANGUAGE_KEY, 'zh-cn')
        self.client.login(username=self.instructor.username, password='test')

        self.student = UserFactory.create()
        UserPreference.set_preference(self.student, LANGUAGE_KEY, 'fr')
开发者ID:alexmerser,项目名称:lms,代码行数:13,代码来源:test_api_email_localization.py

示例4: set_language

# 需要导入模块: from openedx.core.djangoapps.user_api.models import UserPreference [as 别名]
# 或者: from openedx.core.djangoapps.user_api.models.UserPreference import set_preference [as 别名]
def set_language(request):
    """
    This view is called when the user would like to set a language preference
    """
    user = request.user
    lang_pref = request.POST.get('language', None)

    if lang_pref:
        UserPreference.set_preference(user, LANGUAGE_KEY, lang_pref)
        return HttpResponse('{"success": true}')

    return HttpResponseBadRequest('no language provided')
开发者ID:JacobWay,项目名称:edx-platform,代码行数:14,代码来源:views.py

示例5: test_language_in_user_prefs

# 需要导入模块: from openedx.core.djangoapps.user_api.models import UserPreference [as 别名]
# 或者: from openedx.core.djangoapps.user_api.models.UserPreference import set_preference [as 别名]
 def test_language_in_user_prefs(self):
     # language set in the user preferences and not the session
     UserPreference.set_preference(self.user, LANGUAGE_KEY, 'eo')
     self.middleware.process_request(self.request)
     self.assertEquals(self.request.session['django_language'], 'eo')
开发者ID:JacobWay,项目名称:edx-platform,代码行数:7,代码来源:test_middleware.py


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