def update_display_settings_backend(request, user_profile, twenty_four_hour_time=REQ(validator=check_bool, default=None), default_language=REQ(validator=check_string, default=None), left_side_userlist=REQ(validator=check_bool, default=None)): # type: (HttpRequest, UserProfile, Optional[bool], Optional[str], Optional[bool]) -> HttpResponse if (default_language is not None and default_language not in get_available_language_codes()): raise JsonableError(_("Invalid language '%s'" % (default_language,))) result = {} # type: Dict[str, Any] if (default_language is not None and user_profile.default_language != default_language): do_change_default_language(user_profile, default_language) result['default_language'] = default_language elif (twenty_four_hour_time is not None and user_profile.twenty_four_hour_time != twenty_four_hour_time): do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time) result['twenty_four_hour_time'] = twenty_four_hour_time elif (left_side_userlist is not None and user_profile.left_side_userlist != left_side_userlist): do_change_left_side_userlist(user_profile, left_side_userlist) result['left_side_userlist'] = left_side_userlist return json_success(result)
def update_display_settings_backend(request, user_profile, twenty_four_hour_time=REQ(validator=check_bool, default=None), default_language=REQ(validator=check_string, default=None), left_side_userlist=REQ(validator=check_bool, default=None), emoji_alt_code=REQ(validator=check_bool, default=None)): # type: (HttpRequest, UserProfile, Optional[bool], Optional[str], Optional[bool], Optional[bool]) -> HttpResponse if (default_language is not None and default_language not in get_available_language_codes()): raise JsonableError(_("Invalid language '%s'" % (default_language,))) result = {} # type: Dict[str, Any] if (default_language is not None and user_profile.default_language != default_language): do_change_default_language(user_profile, default_language) result['default_language'] = default_language elif (twenty_four_hour_time is not None and user_profile.twenty_four_hour_time != twenty_four_hour_time): do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time) result['twenty_four_hour_time'] = twenty_four_hour_time elif (left_side_userlist is not None and user_profile.left_side_userlist != left_side_userlist): do_change_left_side_userlist(user_profile, left_side_userlist) result['left_side_userlist'] = left_side_userlist elif (emoji_alt_code is not None and user_profile.emoji_alt_code != emoji_alt_code): do_change_emoji_alt_code(user_profile, emoji_alt_code) result['emoji_alt_code'] = emoji_alt_code return json_success(result)
def json_language_setting(request, user_profile, default_language=REQ(validator=check_string, default=None)): # type: (HttpRequest, UserProfile, Optional[str]) -> HttpResponse result = {} if (default_language is not None and user_profile.default_language != default_language): do_change_default_language(user_profile, default_language) result['default_language'] = default_language return json_success(result)
def json_language_setting(request, user_profile, default_language=REQ(validator=check_string, default=None)): # type: (HttpRequest, UserProfile, Optional[str]) -> HttpResponse result = {} if (default_language is not None and user_profile.default_language != default_language): if default_language in get_available_language_codes(): do_change_default_language(user_profile, default_language) else: raise JsonableError(_("Invalid language '%s'" % (default_language,))) result['default_language'] = default_language return json_success(result)