diff --git a/elrte/settings.py b/elrte/settings.py index 1dc6c99..bb978fb 100644 --- a/elrte/settings.py +++ b/elrte/settings.py @@ -2,6 +2,7 @@ These are the default configuration options for Django-elRTE """ + import os from django.conf import settings @@ -22,9 +23,9 @@ os.path.join(settings.STATIC_URL, 'elrte/css/')) if ELRTE_DEBUG: - URL = getattr(settings, 'ELRTE_JS_URL', '%selrte.full.js' % JS_BASE_URL) + URL = getattr(settings, 'ELRTE_JS_URL', f'{JS_BASE_URL}elrte.full.js') else: - URL = getattr(settings, 'ELRTE_JS_URL', '%selrte.min.js' % JS_BASE_URL) + URL = getattr(settings, 'ELRTE_JS_URL', f'{JS_BASE_URL}elrte.min.js') LOAD_JQUERY = getattr(settings, 'ELRTE_LOAD_JQUERY', True) LOAD_JQUERYUI = getattr(settings, 'ELRTE_LOAD_JQUERYUI', True) @@ -32,22 +33,19 @@ JS_URL = [] if LOAD_JQUERY: - JS_URL.append("%sjquery-1.6.1.min.js" % JS_BASE_URL) + JS_URL.append(f"{JS_BASE_URL}jquery-1.6.1.min.js") if LOAD_JQUERYUI: - JS_URL.append("%sjquery-ui-1.8.13.custom.min.js" % JS_BASE_URL) + JS_URL.append(f"{JS_BASE_URL}jquery-ui-1.8.13.custom.min.js") JS_URL.append(URL) CSS_URL = [] if LOAD_JQUERYUI: - CSS_URL.append( - "%ssmoothness/jquery-ui-1.8.13.custom.css" % CSS_BASE_URL - ) - -CSS_URL.extend([ - "%selrte.full.css" % CSS_BASE_URL, - "%sdjango-elrte.css" % CSS_BASE_URL, -]) + CSS_URL.append(f"{CSS_BASE_URL}smoothness/jquery-ui-1.8.13.custom.css") + +CSS_URL.extend( + [f"{CSS_BASE_URL}elrte.full.css", f"{CSS_BASE_URL}django-elrte.css"] +) ADMIN_FIELDS = getattr(settings, 'ELRTE_ADMIN_FIELDS', {}) \ No newline at end of file diff --git a/elrte/widgets.py b/elrte/widgets.py index 5f6ceb1..10e3cdc 100644 --- a/elrte/widgets.py +++ b/elrte/widgets.py @@ -16,7 +16,7 @@ ELRTE_DEFAULT_OPTIONS = { 'doctype': '', 'cssClass': 'el-rte', - 'cssfiles': ['%selrte-inner.css' % elrte.settings.CSS_BASE_URL], + 'cssfiles': [f'{elrte.settings.CSS_BASE_URL}elrte-inner.css'], 'absoluteURLs': True, 'allowSource': True, 'lang': 'en', @@ -24,10 +24,11 @@ 'height': None, 'fmAllow': True, 'toolbar': 'normal', - # 'fmOpen': FileManagerOpener(), } -ELRTE_LANG_INCLUSION = 'i18n/elrte.%s.js' % getattr(ELRTE_DEFAULT_OPTIONS, 'lang', 'en') +ELRTE_LANG_INCLUSION = ( + f"i18n/elrte.{getattr(ELRTE_DEFAULT_OPTIONS, 'lang', 'en')}.js" +) class FileManagerOpener(object): @@ -68,7 +69,7 @@ def render(self, name, value, attrs=None): final_attrs = self.build_attrs(attrs) final_attrs['name'] = name config = self.get_config(name) - html = [u'%s' % (flatatt(final_attrs), escape(value))] + html = [f'{escape(value)}'] html.append(u'' % {'name': name}) html.append(config) return mark_safe(u'\n'.join(html)) @@ -91,25 +92,16 @@ class AdminElrteTextareaWidget(ElrteTextareaWidget, admin_widgets.AdminTextareaW def get_language_config(content_language=None): language = get_language()[:2] - if content_language: - content_language = content_language[:2] - else: - content_language = language - - config = {} - config['language'] = language - + content_language = content_language[:2] if content_language else language + config = {'language': language} lang_names = SortedDict() for lang, name in settings.LANGUAGES: if lang[:2] not in lang_names: lang_names[lang[:2]] = [] lang_names[lang[:2]].append(_(name)) sp_langs = [] for lang, names in lang_names.items(): - if lang == content_language: - default = '+' - else: - default = '' - sp_langs.append(u'%s%s=%s' % (default, ' / '.join(names), lang)) + default = '+' if lang == content_language else '' + sp_langs.append(f"{default}{' / '.join(names)}={lang}") config['spellchecker_languages'] = ','.join(sp_langs)