diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 45aaf1c49..c781efc36 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,12 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.12.20 +------- +2018-02-24 + +- Minor Python 2 fixes. + 0.12.19 ------- 2018-02-21 diff --git a/docs/changelog.rst b/docs/changelog.rst index 45aaf1c49..c781efc36 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,12 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.12.20 +------- +2018-02-24 + +- Minor Python 2 fixes. + 0.12.19 ------- 2018-02-21 diff --git a/examples/requirements.txt b/examples/requirements.txt index 2facce798..c68ea493c 100644 --- a/examples/requirements.txt +++ b/examples/requirements.txt @@ -1 +1 @@ --r requirements/django_1_9.txt \ No newline at end of file +-r requirements/django_1_11.txt \ No newline at end of file diff --git a/setup.py b/setup.py index cf9148aaa..911b6defd 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from distutils.version import LooseVersion from setuptools import setup, find_packages -version = '0.12.19' +version = '0.12.20' # *************************************************************************** # ************************** Python version ********************************* diff --git a/src/fobi/__init__.py b/src/fobi/__init__.py index 3571b01f5..e0c204e2e 100644 --- a/src/fobi/__init__.py +++ b/src/fobi/__init__.py @@ -1,5 +1,5 @@ __title__ = 'django-fobi' -__version__ = '0.12.19' +__version__ = '0.12.20' __author__ = 'Artur Barseghyan ' __copyright__ = '2014-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' diff --git a/src/fobi/base.py b/src/fobi/base.py index 669862017..8dd45e36e 100644 --- a/src/fobi/base.py +++ b/src/fobi/base.py @@ -49,6 +49,7 @@ CUSTOM_THEME_DATA, DEBUG, DEFAULT_THEME, + FAIL_ON_ERRORS_IN_FORM_ELEMENT_PLUGINS, FAIL_ON_ERRORS_IN_FORM_HANDLER_PLUGINS, FAIL_ON_ERRORS_IN_FORM_WIZARD_HANDLER_PLUGINS, FAIL_ON_MISSING_FORM_ELEMENT_PLUGINS, @@ -1665,7 +1666,10 @@ def get_origin_kwargs_update_func_results(self, kwargs_update_func, if kwargs_update: return kwargs_update except Exception as err: - logger.debug(str(err)) + if FAIL_ON_ERRORS_IN_FORM_ELEMENT_PLUGINS: + raise err + else: + logger.error(str(err)) return {} def _submit_plugin_form_data(self, form_entry, request, form, diff --git a/src/fobi/contrib/plugins/form_handlers/mail/mixins.py b/src/fobi/contrib/plugins/form_handlers/mail/mixins.py index cbfd62989..c01c5f47f 100644 --- a/src/fobi/contrib/plugins/form_handlers/mail/mixins.py +++ b/src/fobi/contrib/plugins/form_handlers/mail/mixins.py @@ -84,7 +84,7 @@ def send_email(self, rendered_data, files): send_mail( safe_text(self.data.subject), - "{0}\n\n{1}".format( + u"{0}\n\n{1}".format( safe_text(self.data.body), ''.join(rendered_data) ), diff --git a/src/fobi/helpers.py b/src/fobi/helpers.py index 1a3622576..e6582ba19 100644 --- a/src/fobi/helpers.py +++ b/src/fobi/helpers.py @@ -21,7 +21,7 @@ from django.http import HttpResponse from django.templatetags.static import static from django.test.client import RequestFactory -from django.utils.encoding import force_text +from django.utils.encoding import force_text, smart_text from django.utils.html import format_html_join from django.utils.translation import ugettext_lazy as _ @@ -108,10 +108,11 @@ def safe_text(text): :return str: """ - if PY3: - return force_text(text, encoding='utf-8') - else: - return force_text(text, encoding='utf-8').encode('utf-8') + return smart_text(text) + # if PY3: + # return force_text(text, encoding='utf-8') + # else: + # return force_text(text, encoding='utf-8').encode('utf-8') def lists_overlap(sub, main): diff --git a/src/fobi/tests/data.py b/src/fobi/tests/data.py index f203167de..af3a8e5e3 100644 --- a/src/fobi/tests/data.py +++ b/src/fobi/tests/data.py @@ -1,3 +1,4 @@ +# from __future__ import unicode_literals import copy from collections import OrderedDict import datetime @@ -238,6 +239,13 @@ 'help_text': "Lorem ipsum text area", 'required': True, }, + + # Add a "Text" (text input) form element + # force_text(TextInputPlugin.name): { + # 'label': u"Անուն", + # 'help_text': u"Անուն", + # 'required': True, + # }, } TEST_FORM_FIELD_DATA = { @@ -266,6 +274,7 @@ 'test_text': 'Lorem ipsum', 'test_text_area': 'Dolor sit amet', 'test_url_input': 'http://dev.example.com', + # 'test_unicode_text': u'Անուն', } TEST_FORM_HANDLER_PLUGIN_DATA = { @@ -598,7 +607,20 @@ 'semper lorem rhoncus sem cras amet."' '}' ) - ) + ), + # ( + # 'unicode_name', + # ( + # TextInputPlugin.uid, + # '{' + # '"name": "unicode_name", ' + # '"required": true, ' + # '"max_length": 200, ' + # '"label": u"Անուն", ' + # '"placeholder": u"Անուն"' + # '}' + # ) + # ), ]) TEST_DYNAMIC_FORMS_DEFINITION_DATA_DRF = copy.copy( @@ -627,6 +649,7 @@ 'special_fields': FAKER.pystr(), 'number_of_children': FAKER.pyint(), 'bio': FAKER.text(), + # 'unicode_name': u'Անուն', } TEST_DYNAMIC_FORMS_PUT_DATA = copy.copy(TEST_DYNAMIC_FORMS_PUT_DATA_ALL) @@ -664,5 +687,11 @@ (u'bio', OrderedDict([(u'type', u'string'), (u'required', True), (u'read_only', False), - (u'label', u'Biography')])) + (u'label', u'Biography')])), + # (u'unicode_name', OrderedDict([(u'type', u'string'), + # (u'required', True), + # (u'read_only', False), + # (u'label', u'Անուն'), + # (u'max_length', 200), + # (u'placeholder', u'Անուն')])), ]) diff --git a/src/fobi/utils.py b/src/fobi/utils.py index 01181bbad..a72ef07ff 100644 --- a/src/fobi/utils.py +++ b/src/fobi/utils.py @@ -258,7 +258,6 @@ def get_user_plugins_grouped(get_allowed_plugin_uids_func, ordered_registered_plugins = OrderedDict() for key, prop in sorted(registered_plugins.items()): - import ipdb; ipdb.set_trace() if sort_by_value: ordered_registered_plugins[key] = sorted(prop, key=lambda t: t[1]) else: @@ -610,13 +609,17 @@ def append_edit_and_delete_links_to_field(form_element_plugin, help_text = '' data_dict = { - 'help_text': "{0} {1}".format(help_text, help_text_extra), + 'help_text': u"{0} {1}".format(help_text, help_text_extra), } label = safe_text(getattr(form_element_plugin.data, 'label', '')) data_dict.update( - {'label': "{0} ({1})".format(label, - safe_text(form_element_plugin.name))} + { + 'label': u"{0} ({1})".format( + label, + safe_text(form_element_plugin.name) + ) + } ) # if 'hidden' == form_element_plugin.uid: