diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 128a8a04c..78cf53fd3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,13 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.19.2 +------ +2022-07-14 + +- Make it easier to get initial data for the `ViewFormEntry` view. +- Apply black and isort on entire code base. + 0.19.1 ------ 2022-07-12 diff --git a/docs/changelog.rst b/docs/changelog.rst index 128a8a04c..78cf53fd3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,13 @@ are used for versioning (schema follows below): 0.3.4 to 0.4). - All backwards incompatible changes are mentioned in this document. +0.19.2 +------ +2022-07-14 + +- Make it easier to get initial data for the `ViewFormEntry` view. +- Apply black and isort on entire code base. + 0.19.1 ------ 2022-07-12 diff --git a/setup.py b/setup.py index 5d80f3675..607e9c63b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from distutils.version import LooseVersion from setuptools import setup, find_packages -version = "0.19.1" +version = "0.19.2" # *************************************************************************** # ************************** Django version ********************************* diff --git a/src/fobi/__init__.py b/src/fobi/__init__.py index d7ad3dc1f..84443927f 100644 --- a/src/fobi/__init__.py +++ b/src/fobi/__init__.py @@ -1,5 +1,5 @@ __title__ = "django-fobi" -__version__ = "0.19.1" +__version__ = "0.19.2" __author__ = "Artur Barseghyan " __copyright__ = "2014-2022 Artur Barseghyan" __license__ = "GPL 2.0/LGPL 2.1" diff --git a/src/fobi/views/class_based.py b/src/fobi/views/class_based.py index eab0a6348..abd689fa8 100644 --- a/src/fobi/views/class_based.py +++ b/src/fobi/views/class_based.py @@ -1609,6 +1609,20 @@ def get_essential_objects( form_cls, ) + def get_initial_data(self, request, form_entry): + """Get initial data. + + :param request: HTTP request. + :param form_entry: Form entry object. + :return: Dictionary with initial form data. + """ + # Providing initial form data by feeding entire GET dictionary + # to the form, if ``GET_PARAM_INITIAL_DATA`` is present in the + # GET. + if GET_PARAM_INITIAL_DATA in request.GET: + return {"initial": request.GET} + return {} + def inactive_form_response(self, request, form_entry): context = { "form_entry": form_entry, @@ -1650,12 +1664,8 @@ def get(self, request, *args, **kwargs): request, ) - # Providing initial form data by feeding entire GET dictionary - # to the form, if ``GET_PARAM_INITIAL_DATA`` is present in the - # GET. - kwargs = {} - if GET_PARAM_INITIAL_DATA in request.GET: - kwargs = {"initial": request.GET} + # Get initial data. + kwargs = self.get_initial_data(request, form_entry) form = form_cls(**kwargs) # In debug mode, try to identify possible problems.