Skip to content

Commit

Permalink
Merge with v0.17.x
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Jan 25, 2021
2 parents 1d58386 + cbe59d8 commit a998fea
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 15 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.17.1
------
2021-01-25

.. note::

Release dedicated to defenders of Armenia and Artsakh (Nagorno Karabakh)
and all the victims of Turkish and Azerbaijani aggression.

- Replace outdated `simplejson` with `json`.

0.17
----
2020-12-28
Expand Down
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.17.1
------
2021-01-25

.. note::

Release dedicated to defenders of Armenia and Artsakh (Nagorno Karabakh)
and all the victims of Turkish and Azerbaijani aggression.

- Replace outdated `simplejson` with `json`.

0.17
----
2020-12-28
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from distutils.version import LooseVersion
from setuptools import setup, find_packages

version = '0.17'
version = '0.17.1'

# ***************************************************************************
# ************************** Django version *********************************
Expand Down
2 changes: 1 addition & 1 deletion src/fobi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'django-fobi'
__version__ = '0.17'
__version__ = '0.17.1'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2014-2020 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
Expand Down
7 changes: 4 additions & 3 deletions src/fobi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import json

from django import forms
from django.core.serializers.json import DjangoJSONEncoder
from django.forms import ModelForm
from django.forms.utils import ErrorList
from django.http import Http404
Expand Down Expand Up @@ -802,7 +803,7 @@ def _get_plugin_data(self, fields, request=None, json_format=True):
if not json_format:
return data

return json.dumps(data)
return json.dumps(data, cls=DjangoJSONEncoder)

def get_plugin_data(self, request=None, json_format=True):
"""Get plugin data.
Expand Down Expand Up @@ -1404,7 +1405,7 @@ def get_cloned_plugin_data(self, update={}):
for prop, value in update.items():
data.update({prop: value})

return json.dumps(data)
return json.dumps(data, cls=DjangoJSONEncoder)

def get_updated_plugin_data(self, update={}):
"""Get updated plugin data.
Expand All @@ -1423,7 +1424,7 @@ def get_updated_plugin_data(self, update={}):
for prop, value in update.items():
data.update({prop: value})

return json.dumps(data)
return json.dumps(data, cls=DjangoJSONEncoder)

def pre_processor(self):
"""Pre-processor (callback).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import

from django.apps import apps
from django.core.serializers.json import DjangoJSONEncoder
from django.forms.models import ModelMultipleChoiceField
from django.forms.widgets import SelectMultiple
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -110,7 +111,10 @@ def submit_plugin_form_data(self, form_entry, request, form,

# Overwrite ``cleaned_data`` of the ``form`` with object qualifier.
if values:
form.cleaned_data[self.data.name] = json.dumps(values)
form.cleaned_data[self.data.name] = json.dumps(
values,
cls=DjangoJSONEncoder
)
else:
del form.cleaned_data[self.data.name]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import

from django.apps import apps
from django.core.serializers.json import DjangoJSONEncoder
from django.forms.widgets import SelectMultiple
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -102,7 +103,10 @@ def submit_plugin_form_data(self, form_entry, request, form,

# Overwrite ``cleaned_data`` of the ``form`` with object qualifier.
if values:
form.cleaned_data[self.data.name] = json.dumps(values)
form.cleaned_data[self.data.name] = json.dumps(
values,
cls=DjangoJSONEncoder
)
else:
del form.cleaned_data[self.data.name]

Expand Down
15 changes: 10 additions & 5 deletions src/fobi/contrib/plugins/form_handlers/db_store/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import json

from django.core.serializers.json import DjangoJSONEncoder
from django.utils.translation import gettext_lazy as _
from django.urls import reverse

from django.core.serializers.json import DjangoJSONEncoder

from .....base import (
FormHandlerPlugin,
FormWizardHandlerPlugin,
Expand Down Expand Up @@ -85,7 +84,10 @@ def save_form_data_entry(self,
saved_form_data_entry = SavedFormDataEntry(
form_entry=form_entry,
user=request.user if request.user and request.user.pk else None,
form_data_headers=json.dumps(field_name_to_label_map),
form_data_headers=json.dumps(
field_name_to_label_map,
cls=DjangoJSONEncoder
),
saved_data=json.dumps(cleaned_data, cls=DjangoJSONEncoder)
)
saved_form_data_entry.save()
Expand Down Expand Up @@ -176,8 +178,11 @@ def run(self, form_wizard_entry, request, form_list, form_wizard,
saved_form_wizard_data_entry = SavedFormWizardDataEntry(
form_wizard_entry=form_wizard_entry,
user=request.user if request.user and request.user.pk else None,
form_data_headers=json.dumps(field_name_to_label_map),
saved_data=json.dumps(cleaned_data)
form_data_headers=json.dumps(
field_name_to_label_map,
cls=DjangoJSONEncoder
),
saved_data=json.dumps(cleaned_data, cls=DjangoJSONEncoder)
)
saved_form_wizard_data_entry.save()

Expand Down
9 changes: 7 additions & 2 deletions src/fobi/contrib/plugins/form_handlers/db_store/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import json

from django.core.serializers.json import DjangoJSONEncoder

from fobi.base import (
FormCallback,
get_processed_form_data,
Expand Down Expand Up @@ -59,7 +61,10 @@ def callback(self, form_entry, request, form):
saved_form_data_entry = SavedFormDataEntry(
form_entry=form_entry,
user=request.user if request.user and request.user.pk else None,
form_data_headers=json.dumps(field_name_to_label_map),
saved_data=json.dumps(cleaned_data)
form_data_headers=json.dumps(
field_name_to_label_map,
cls=DjangoJSONEncoder
),
saved_data=json.dumps(cleaned_data, cls=DjangoJSONEncoder)
)
saved_form_data_entry.save()
4 changes: 3 additions & 1 deletion src/fobi/form_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json

from django.core.serializers.json import DjangoJSONEncoder
from six import text_type

from .base import BaseRegistry
Expand Down Expand Up @@ -104,7 +105,8 @@ def import_data(self, form_properties, form_data):

# Assign form data
form_element_entry.plugin_data = json.dumps(
self.extract_field_properties(field_data)
self.extract_field_properties(field_data),
cls=DjangoJSONEncoder
)

# Assign position in form
Expand Down

0 comments on commit a998fea

Please sign in to comment.