def test_tinymce(): """tests the tinymce editor setup""" errors = list() if 'tinymce' not in django_settings.INSTALLED_APPS: errors.append("add 'tinymce', to the INSTALLED_APPS") required_attrs = ( 'TINYMCE_COMPRESSOR', 'TINYMCE_JS_ROOT', 'TINYMCE_URL', 'TINYMCE_DEFAULT_CONFIG' ) missing_attrs = list() for attr in required_attrs: if not hasattr(django_settings, attr): missing_attrs.append(attr) if missing_attrs: errors.append('add missing settings: %s' % ', '.join(missing_attrs)) #check compressor setting compressor_on = getattr(django_settings, 'TINYMCE_COMPRESSOR', False) if compressor_on is False: errors.append('add line: TINYMCE_COMPRESSOR = True') #check js root setting - before version 0.7.44 we used to have #"common" skin and after we combined it into the default js_root = getattr(django_settings, 'TINYMCE_JS_ROOT', '') old_relative_js_path = 'common/media/js/tinymce/' relative_js_path = 'default/media/js/tinymce/' expected_js_root = os.path.join(django_settings.STATIC_ROOT, relative_js_path) old_expected_js_root = os.path.join(django_settings.STATIC_ROOT, old_relative_js_path) if os.path.normpath(js_root) != os.path.normpath(expected_js_root): error_tpl = "add line: TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, '%s')" if os.path.normpath(js_root) == os.path.normpath(old_expected_js_root): error_tpl += '\nNote: we have moved files from "common" into "default"' errors.append(error_tpl % relative_js_path) #check url setting url = getattr(django_settings, 'TINYMCE_URL', '') expected_url = django_settings.STATIC_URL + relative_js_path old_expected_url = django_settings.STATIC_URL + old_relative_js_path if urls_equal(url, expected_url) is False: error_tpl = "add line: TINYMCE_URL = STATIC_URL + '%s'" if urls_equal(url, old_expected_url): error_tpl += '\nNote: we have moved files from "common" into "default"' errors.append(error_tpl % relative_js_path) if errors: header = 'Please add the tynymce editor configuration ' + \ 'to your settings.py file.' footer = 'You might want to use this sample configuration ' + \ 'as template:\n\n' + get_tinymce_sample_config() print_errors(errors, header=header, footer=footer)
def test_tinymce(): """tests the tinymce editor setup""" errors = list() if 'tinymce' not in django_settings.INSTALLED_APPS: errors.append("add 'tinymce', to the INSTALLED_APPS") required_attrs = ( 'TINYMCE_COMPRESSOR', 'TINYMCE_JS_ROOT', 'TINYMCE_URL', 'TINYMCE_DEFAULT_CONFIG' ) missing_attrs = list() for attr in required_attrs: if not hasattr(django_settings, attr): missing_attrs.append(attr) if missing_attrs: errors.append('add missing settings: %s' % ', '.join(missing_attrs)) #check compressor setting compressor_on = getattr(django_settings, 'TINYMCE_COMPRESSOR', False) if compressor_on is False: errors.append('add line: TINYMCE_COMPRESSOR = True') #check js root setting js_root = getattr(django_settings, 'TINYMCE_JS_ROOT', '') relative_js_path = 'common/media/js/tinymce/' expected_js_root = os.path.join(django_settings.STATIC_ROOT, relative_js_path) if os.path.normpath(js_root) != os.path.normpath(expected_js_root): js_root_template = "add line: TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, '%s')" errors.append(js_root_template % relative_js_path) #check url setting url = getattr(django_settings, 'TINYMCE_URL', '') expected_url = django_settings.STATIC_URL + relative_js_path if urls_equal(url, expected_url) is False: js_url_template = "add line: TINYMCE_URL = STATIC_URL + '%s'" errors.append(js_url_template % relative_js_path) if errors: header = 'Please add the tynymce editor configuration ' + \ 'to your settings.py file.' footer = 'You might want to use this sample configuration ' + \ 'as template:\n\n' + get_tinymce_sample_config() print_errors(errors, header=header, footer=footer)
def test_tinymce(): """tests the tinymce editor setup""" errors = list() if "tinymce" not in django_settings.INSTALLED_APPS: errors.append("add 'tinymce', to the INSTALLED_APPS") required_attrs = ("TINYMCE_COMPRESSOR", "TINYMCE_JS_ROOT", "TINYMCE_URL", "TINYMCE_DEFAULT_CONFIG") missing_attrs = list() for attr in required_attrs: if not hasattr(django_settings, attr): missing_attrs.append(attr) if missing_attrs: errors.append("add missing settings: %s" % ", ".join(missing_attrs)) # check compressor setting compressor_on = getattr(django_settings, "TINYMCE_COMPRESSOR", False) if compressor_on is False: errors.append("add line: TINYMCE_COMPRESSOR = True") # todo: add pointer to instructions on how to debug tinymce: # 1) add ('tiny_mce', os.path.join(ASKBOT_ROOT, 'media/js/tinymce')), # to STATIFILES_DIRS # 2) add this to the main urlconf: # ( # r'^m/(?P<path>.*)$', # 'django.views.static.serve', # {'document_root': static_root} # ), # 3) set `TINYMCE_COMPRESSOR = False` # 4) set DEBUG = False # then - tinymce compressing will be disabled and it will # be possible to debug custom tinymce plugins that are used with askbot config = getattr(django_settings, "TINYMCE_DEFAULT_CONFIG", None) if config: if "convert_urls" in config: if config["convert_urls"] is not False: message = "set 'convert_urls':False in TINYMCE_DEFAULT_CONFIG" errors.append(message) else: message = "add to TINYMCE_DEFAULT_CONFIG\n'convert_urls': False," errors.append(message) # check js root setting - before version 0.7.44 we used to have # "common" skin and after we combined it into the default js_root = getattr(django_settings, "TINYMCE_JS_ROOT", "") old_relative_js_path = "common/media/js/tinymce/" relative_js_path = "default/media/js/tinymce/" expected_js_root = os.path.join(django_settings.STATIC_ROOT, relative_js_path) old_expected_js_root = os.path.join(django_settings.STATIC_ROOT, old_relative_js_path) if os.path.normpath(js_root) != os.path.normpath(expected_js_root): error_tpl = "add line: TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, '%s')" if os.path.normpath(js_root) == os.path.normpath(old_expected_js_root): error_tpl += '\nNote: we have moved files from "common" into "default"' errors.append(error_tpl % relative_js_path) # check url setting url = getattr(django_settings, "TINYMCE_URL", "") expected_url = django_settings.STATIC_URL + relative_js_path old_expected_url = django_settings.STATIC_URL + old_relative_js_path if urls_equal(url, expected_url) is False: error_tpl = "add line: TINYMCE_URL = STATIC_URL + '%s'" if urls_equal(url, old_expected_url): error_tpl += '\nNote: we have moved files from "common" into "default"' errors.append(error_tpl % relative_js_path) if errors: header = "Please add the tynymce editor configuration " + "to your settings.py file." footer = "You might want to use this sample configuration " + "as template:\n\n" + get_tinymce_sample_config() print_errors(errors, header=header, footer=footer)
def test_tinymce(): """tests the tinymce editor setup""" errors = list() if 'tinymce' not in django_settings.INSTALLED_APPS: errors.append("add 'tinymce', to the INSTALLED_APPS") required_attrs = ( 'TINYMCE_COMPRESSOR', 'TINYMCE_JS_ROOT', 'TINYMCE_URL', 'TINYMCE_DEFAULT_CONFIG' ) missing_attrs = list() for attr in required_attrs: if not hasattr(django_settings, attr): missing_attrs.append(attr) if missing_attrs: errors.append('add missing settings: %s' % ', '.join(missing_attrs)) #check compressor setting compressor_on = getattr(django_settings, 'TINYMCE_COMPRESSOR', False) if compressor_on is False: errors.append('add line: TINYMCE_COMPRESSOR = True') #todo: add pointer to instructions on how to debug tinymce: #1) add ('tiny_mce', os.path.join(ASKBOT_ROOT, 'media/js/tinymce')), # to STATIFILES_DIRS #2) add this to the main urlconf: # ( # r'^m/(?P<path>.*)$', # 'django.views.static.serve', # {'document_root': static_root} # ), #3) set `TINYMCE_COMPRESSOR = False` #4) set DEBUG = False #then - tinymce compressing will be disabled and it will #be possible to debug custom tinymce plugins that are used with askbot config = getattr(django_settings, 'TINYMCE_DEFAULT_CONFIG', None) if config: if 'convert_urls' in config: if config['convert_urls'] is not False: message = "set 'convert_urls':False in TINYMCE_DEFAULT_CONFIG" errors.append(message) else: message = "add to TINYMCE_DEFAULT_CONFIG\n'convert_urls': False," errors.append(message) #check js root setting - before version 0.7.44 we used to have #"common" skin and after we combined it into the default js_root = getattr(django_settings, 'TINYMCE_JS_ROOT', '') old_relative_js_path = 'common/media/js/tinymce/' relative_js_path = 'default/media/js/tinymce/' expected_js_root = os.path.join(django_settings.STATIC_ROOT, relative_js_path) old_expected_js_root = os.path.join(django_settings.STATIC_ROOT, old_relative_js_path) if os.path.normpath(js_root) != os.path.normpath(expected_js_root): error_tpl = "add line: TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, '%s')" if os.path.normpath(js_root) == os.path.normpath(old_expected_js_root): error_tpl += '\nNote: we have moved files from "common" into "default"' errors.append(error_tpl % relative_js_path) #check url setting url = getattr(django_settings, 'TINYMCE_URL', '') expected_url = django_settings.STATIC_URL + relative_js_path old_expected_url = django_settings.STATIC_URL + old_relative_js_path if urls_equal(url, expected_url) is False: error_tpl = "add line: TINYMCE_URL = STATIC_URL + '%s'" if urls_equal(url, old_expected_url): error_tpl += '\nNote: we have moved files from "common" into "default"' errors.append(error_tpl % relative_js_path) if errors: header = 'Please add the tynymce editor configuration ' + \ 'to your settings.py file.' footer = 'You might want to use this sample configuration ' + \ 'as template:\n\n' + get_tinymce_sample_config() print_errors(errors, header=header, footer=footer)