예제 #1
0
    def handle(self, request, data):
        response = shortcuts.redirect(request.build_absolute_uri())

        lang_code = data['language']
        response = functions.save_config_value(request, response,
                                               settings.LANGUAGE_COOKIE_NAME,
                                               lang_code)

        response = functions.save_config_value(
            request, response, 'django_timezone',
            pytz.timezone(data['timezone']).zone)

        response = functions.save_config_value(request, response,
                                               'API_RESULT_PAGE_SIZE',
                                               data['pagesize'])

        response = functions.save_config_value(request, response,
                                               'INSTANCE_LOG_LENGTH',
                                               data['instance_log_length'])

        with translation.override(lang_code):
            messages.success(request,
                             encoding.force_text(_("Settings saved.")))

        return response
예제 #2
0
파일: forms.py 프로젝트: andymcc/horizon
    def handle(self, request, data):
        response = shortcuts.redirect(request.build_absolute_uri())

        lang_code = data['language']
        if lang_code and translation.check_for_language(lang_code):
            response = functions.save_config_value(
                request, response, settings.LANGUAGE_COOKIE_NAME, lang_code)

        response = functions.save_config_value(
            request, response, 'django_timezone',
            pytz.timezone(data['timezone']).zone)

        response = functions.save_config_value(
            request, response, 'API_RESULT_PAGE_SIZE', data['pagesize'])

        response = functions.save_config_value(
            request, response, 'INSTANCE_LOG_LENGTH',
            data['instance_log_length'])

        with translation.override(lang_code):
            messages.success(request,
                             encoding.force_text(_("Settings saved.")))

        return response