python-django-crispy-forms-foundation-1.1.0/ 0000775 0000000 0000000 00000000000 15035575614 0021104 5 ustar 00root root 0000000 0000000 python-django-crispy-forms-foundation-1.1.0/.gitignore 0000664 0000000 0000000 00000000774 15035575614 0023104 0 ustar 00root root 0000000 0000000 # virtualenv .venv venv # Packaging build dist *.egg-info # sqlite DB db.sqlite3 *.db # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # Site media /data/ # Settings /sandbox/settings/local.py # Unit test / coverage reports htmlcov/ .coverage .cache .pytest_cache nosetests.xml coverage.xml # Temp files *~ .~lock* # Swap files *.sw[po] # JS dependencies node_modules # SASS .sass-cache # logs yarn-error.log # Exported strings & generated translation templates *.pot # Tests .tox python-django-crispy-forms-foundation-1.1.0/.readthedocs.yml 0000664 0000000 0000000 00000000777 15035575614 0024205 0 ustar 00root root 0000000 0000000 # .readthedocs.yml # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Define proper build config build: os: "ubuntu-22.04" tools: python: "3.10" # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py # Optionally set the version of Python and requirements required to build your docs python: install: - method: pip path: . extra_requirements: - doc python-django-crispy-forms-foundation-1.1.0/CHANGELOG.rst 0000664 0000000 0000000 00000032263 15035575614 0023133 0 ustar 00root root 0000000 0000000 .. _crispy-forms-foundation-demo: https://github.com/sveetch/crispy-forms-foundation-demo ========= Changelog ========= Version 1.1.0 - 2025/07/16 ************************** A major release to modernize package, drop some supports and some new ones. No behavior changes or new features have been introduced so this won't break anything on its own. * Specified in README that project is in maintenance mode; * Added support for Python 3.12 and Python 3.13; * Added support for Django>=5.0; * Dropped support for Python<3.10; * Dropped support for Django<5.0; * Added a minimal version to every requirements to help Pip to resolve packages quicker; * Updated package to use ``importlib.metadata`` instead of deprecated ``pkg_resources``; * Added 'pyproject.toml' file to fix PIP warnings about editable install but package config is still in 'setup.cfg' for now; * Moved 'manage.py' script at root of repository to fix issue with latest PIP and setuptools versions that changed how *editable* install works (the sandbox was missing from PYTHONPATH). This have no impact on package itself, it is just for development; * Fixed issue in some templates that was still using template filter ``length_is`` that was removed since Django 5.1; * Updated documentation; * Changed documentation from sphinx-rtd to Furo; * Updated '.readthedocs.yml' to use sandbox.settings.documentation instead of old custom documentation settings; * Updated script to freeze local dependencies; Version 1.0.2 - 2023/10/11 ************************** Fixed missing comma in importations from layout module which caused error when trying to import it. Version 1.0.1 - 2023/08/18 ************************** Added ``.readthedocs.yml`` file to follow service deprecations changes. Version 1.0.0 - 2023/06/04 ************************** **Major release to upgrade to django-crispy-forms 2.0** To migrate to this version you just need to upgrade django-crispy-forms, your code should be safe to work until you made very specific hack around django-crispy-forms internals. * **Dropped support for django-crispy-forms<2.0**; * **Added support for django-crispy-forms 2.0**. * **Added support for Python 3.11**. * **Added support for Django 4.1 and 4.2**. Version 0.9.0 - 2022/10/22 ************************** **Major release to update supports** * **Dropped support for Python<3.8**; * **Dropped support for Django<3.2**; * **Added official support for Python 3.8, 3.9 and 3.10**. * **Added official support for Django 3.2 and 4.0**. * Updated tox configuration to fit to Python and Django supports; * Updated package configuration to split requirements in more extra requirements so Tox won't have to install Sphinx, flake, etc.. only the Pytest suite; * Removed code for old compatibility management from old unsupported Django versions; * Updated Flake8 configuration for ``max-line-length`` value to ``88``; * Fixed all quality issues raised by Flake8 from code and tests; * Updated makefile; * Updated documentation configuration; * Replaced ``sphinx-autobuild`` requirement by ``livereload``; * Fixed some invalid ``code-block`` in docstrings; Version 0.8.0 - 2020/05/20 ************************** **Major release to remove deprecated supports** * Drop Python2 support, minimal Python version support is 3.5; * Drop support for Django prior to 2.0; * Drop support for django-crispy-forms prior to 1.8.1; * Drop support for Foundation 5; * Ensure support for Django 2.2 and 3.0; * Ensure support for django-crispy-forms to 1.9.1; * Removed everything about Foundation 5; Version 0.7.1 - 2019/05/30 ************************** **Minor release to add support for Django 2.2** **This will be the last release to support Django<1.11, Python2 and Foundation5** * Updated tox configuration to cover Django 2.2; * Updated sandbox demo to work with Django 2.2; * Fixed changelog; * Fixed package manifest for supported Django versions; * Fixed README for supported Foundation versions; Version 0.7.0 - 2018/10/08 ************************** **Add support for Django 2.0 and 2.1** * Rewrite package to use ``setup.cfg``; * Add support for Django 2.0 and Django 2.1, close #36; * Django 1.11 support is the last one for Python2; * Change old demo project to more cleaner sandbox; * Included fix from django-crispy-forms#836 for ``FormHelper.field_template`` usage in uniform, close #39; Version 0.6.4 - 2017/07/29 ************************** * Fixed ``layout.buttons.ButtonGroup`` for deprecated ``Context()`` usage; * Fixed tests that performs comparison on html part using ``django.test.html.parse_html``; Version 0.6.3 - 2017/07/16 ************************** This release adds some bugfixes with Abide, new button objects that will replace the old ones a release and Foundation5 support will be removed for the next (non bugfix) release. * Removed ``is-visible`` class and added missing ``data-form-error-for`` attribute in Foundation6 field templates, close #33; * Added new field ``layout.fields.FakeField``; * Fixed tests to always compare rendered value to attempted value, so the test error output diffs are allways in the same order; * Updated documentation; * Adopted new settings structure in ``project/settings/``, removed ``db.sqlite3`` from repository; * Enabled ``django-debug-toolbar`` in development environment and settings for demo only (not for tests); * Moved ``layout.buttons.Hidden`` to ``layout.fields.Hidden``; * Added ``layout.buttons.ButtonElement``, ``layout.buttons.ButtonSubmit`` and ``layout.buttons.ButtonReset`` to button input as real ```` element but keeping old input button behavior for now. **This is on the way to replace respectively** ``Button``, ``Submit`` and ``Reset``. Close #28; * Added ``layout.buttons.InputButton``, ``layout.buttons.InputSubmit`` and ``layout.buttons.InputReset`` to maintain backward compatibility when the button objects will replace the old ones; Version 0.6.2 - 2017/07/03 ************************** * Validated working with Django 1.11 from unittests; * Dropped testing for Django >= 1.10 with Python 2.x in tox config; Version 0.6.1 - 2017/07/03 ************************** * Cleaned tests structure so it runs everywhere; * Fixed tests to pass with tox on every supported Django versions; * Better Makefile; * Upgraded dependancy ``django-crispy-forms`` to ``1.6.1`` since it backward compatible with Django 1.8; * Updated documentation; Version 0.6.0 - 2017/02/11 ************************** This release adds **Foundation for site version 6** support, version 5 support is still available for now. * Added 'foundation-6' templates, copied from @flesser branch ``foundation-6``; * Added ``layout.base.Callout`` element; * Added ``crispy_forms_foundation.templatetags.crispy_forms_foundation_field`` to re-implement ``crispy_field`` filter so we can have the right input field error for Foundation-6; * Added ``layout.buttons.ButtonHolderCallout``; * Chanded ``.help-text`` that is allways a ``
`` in Foundation6 (does not have real meaning in Foundation5);
* Changed ``layout.containers.TabHolder`` so it build a random id for container if ``css_id`` is not given;
* Changed ``layout.containers.Container`` to be able to manage the *active* classname ``active_css_class`` Class attribute or its ``get_active_css_class`` method, and add it a condition to use another class name for Foundation-6 (``is-active`` instead of ``active``);
* Changed layout components to get template pack name from lazy object from ``crispy_forms.utils.TEMPLATE_PACK``;
* Changed documentation for better structure;
* Improved unittests to perform for both foundation-5 and foundation-6 template packs;
* Fixed demo views and forms so they can switch between template packs;
* Fixed layout elements so their template does not include ``TEMPLATE_PACK`` anymore in class defintions;
* Fixed switches for Foundation-6;
* Fixed button group for Foundation-6;
* Fixed ``InlineJustifiedField`` for Foundation-6;
* Fixed error messages for Foundation-6;
* Fixed Accordion for Foundation-6;
* Fixed Tabs for Foundation-6;
Version 0.5.5 - 2017/02/01
**************************
* Dropped support for Python 2.6 and Django<1.8;
* Added default app settings file;
* Added project test structure;
* Added pretty simple tests to cover layout elements which include some code;
* Added demo app taken from crispy-form-foundation-demo;
* Added dev and test requirements files;
* Updated setup.py;
* Added and enabled minified basic assets for Foundation 5 and 6 for test and demo;
* Finished demo urls/templates to work on every Foundation versions;
* Fixed Flake issues;
* Validated test with Tox for Python 2.7, Python 3.5 and Django>=1.8,<=1.10;
Backward compatibility change for foundation-5 template pack:
* Moved Tab link template ``tab-item.html`` to ``tab-link.html``;
* Added ``tab-item.html`` to build the Tab item instead of using the Div default template;
Everything should still work as with previous version.
Version 0.5.4 - 2016/02/26
**************************
* Fixed ``TabHolder`` and ``AccordionHolder`` to have the right *active* behavior on their items: activate the first item with a field error if any, else just activate the first item;
Version 0.5.3 - 2015/09/25
**************************
* Fixed bugs with button layout elements since django-crispy-forms==1.5.x, this is backward compatible with previous django-crispy-forms<1.5.x (with pull request #26 to close #25);
* Fixed package infos and README to be more explicit on Django compatibility (1.4 to 1.8 actually tested);
Version 0.5.2 - 2015/07/12
**************************
* Use relative imports and enforce absolute imports;
* Add german and french translation with i18n;
Version 0.5.1 - 2015/05/02
**************************
* Fix 'disable_csrf' option that was not honored in template forms;
Version 0.5.0 - 2015/04/02
**************************
* Better layout elements organization;
* Merged pull request #20 for *Added Foundation tabs and accordion components based on crispy-forms bootstrap3 implementation*;
* Removed all stuff for Foundation 3 that is not supported anymore;
* Fix TabItem and TabHolder so tab inputs errors are raised to the Tab item;
* Fix AccordionItem and AccordionHolder so accordion inputs errors are raised to the accordion item name;
* Add jquery plugin to add Abide support within tabs and accordions so the input errors are raised to their title name and not hided into contents;
* Update documentation;
Version 0.4.1 - 2015/02/22
**************************
* Added docs for submit button;
* Fixed bug where the class layout property was being used and modified by instances;
* Added Contributors to the doc;
Version 0.4 - 2014/11/29
************************
* Allow unicode characters in the form title in ``forms.FoundationFormMixin``;
* Extended ``forms.FoundationFormMixin.init_helper()`` to allow more customization:
* Renamed attribute input to submit as this is more descriptive
* Allow to give a string which is used as display text for the Submit button
* Allow to give a Submit instance wich is directly used
* Added ``forms.FoundationFormMixin.title_templatestring`` attribute to store template string used to display form title;
* Moved ``forms.FoundationFormMixin.id`` attribute name to ``forms.FoundationFormMixin.form_id``;
Version 0.3.9 - 2014/11/21
**************************
* Added ``FoundationFormMixin``, ``FoundationForm`` and ``FoundationModelForm`` in ``forms.py`` to quickly and automatically create a Foundation layout;
* Added ``InlineSwitchField`` layout element for better switches usage;
Version 0.3.8 - 2014/11/16
**************************
* Redesigned *non field errors*;
* Added abide error message on field;
* Added missing error message and help text on inline field;
Version 0.3.7 - 2014/11/15
**************************
* Added better documentation with Sphinx in 'docs/';
Version 0.3.6
*************
* Added ``ButtonGroup`` to use Foundation's Button groups instead of Button holder;
* Added ``Panel`` layout element that act like a ``Div`` but add a ``panel`` css class name;
Version 0.3.5
*************
* Added ``SwitchField`` field;
Version 0.3.3
*************
* Fix bad template includes in some templates;
Version 0.3.2
*************
* Fixed some css class in templates;
* Added documentation for ``Abide`` usage;
* Added ``ButtonHolderPanel`` layout object;
Version 0.3.1
*************
* Added ``InlineField`` and ``InlineJustifiedField``;
Version 0.3.0 - 2014/03/28
**************************
Some backward incompatible change have been done, be sure to check them before upgrading.
* Removed sample view, url and templates. If needed you can find a Django app sample on `crispy-forms-foundation-demo`_;
* Moved ``foundation`` template pack name and its directory to ``foundation-3``. You have to change your ``settings.CRISPY_TEMPLATE_PACK`` if you used the old one;
* Added ``foundation-5`` template pack, it is now the default template pack;
* Removed camelcase on some css classes :
* ``ctrlHolder`` has changed to ``holder``;
* ``buttonHolder`` has changed to ``button-holder``;
* ``asteriskField`` has changed to ``asterisk``;
* ``errorField`` has changed to ``error``;
* ``formHint`` has changed to ``hint``;
* ``inlineLabel`` has changed to ``inline-label``;
* ``multiField`` has changed to ``multiple-fields``;
Version 0.1.0 - 2012/12/23
**************************
First commit.
python-django-crispy-forms-foundation-1.1.0/LICENCE.txt 0000664 0000000 0000000 00000002063 15035575614 0022710 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2012-2025, David Thenon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
python-django-crispy-forms-foundation-1.1.0/MANIFEST.in 0000664 0000000 0000000 00000000724 15035575614 0022645 0 ustar 00root root 0000000 0000000 include MANIFEST.in
include LICENCE.txt
include README.rst
recursive-include crispy_forms_foundation/templates *
recursive-include crispy_forms_foundation/static *
recursive-include crispy_forms_foundation/locale *
recursive-include crispy_forms_foundation/test_fixtures *
recursive-exclude data *
recursive-exclude docs *
recursive-exclude sandbox *
recursive-exclude tests *
recursive-exclude * .cache
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
python-django-crispy-forms-foundation-1.1.0/Makefile 0000664 0000000 0000000 00000011105 15035575614 0022542 0 ustar 00root root 0000000 0000000 PYTHON_INTERPRETER=python3
VENV_PATH=.venv
PIP=$(VENV_PATH)/bin/pip
DJANGO_MANAGE=$(VENV_PATH)/bin/python ./manage.py
FLAKE=$(VENV_PATH)/bin/flake8
SPHINX_RELOAD=$(VENV_PATH)/bin/python ./docs/sphinx_reload.py
PYTEST=$(VENV_PATH)/bin/pytest
TOX=$(VENV_PATH)/bin/tox
TWINE=$(VENV_PATH)/bin/twine
help:
@echo "Please use \`make {0}
"
def init_helper(self):
# Put required HTML attribute on required fields so they are managed by
# Abide (if enabled)
if "data_abide" in self.attrs:
for field_name, field in self.fields.items():
if hasattr(self, 'instance'):
field_value = getattr(self.instance, field_name, None)
else:
field_value = None
if field.required \
and not ((isinstance(field, FileField) or
isinstance(field, ImageField))
and field_value):
field.widget.attrs["required"] = ""
field.abide_msg = _("This field is required.")
if not self.layout:
# Start with an empty layout
self.helper = FormHelper(self)
else:
# Start from the given layout
self.helper = FormHelper()
self.helper.layout = deepcopy(self.layout)
# Try to reverse form_action url, else fallback to use it as a simple
# string
try:
self.helper.form_action = reverse(self.action)
except NoReverseMatch:
self.helper.form_action = self.action
if self.title:
html = HTML(self.title_templatestring.format(self.title))
self.helper.layout.insert(0, html)
if self.form_id is not None:
self.helper.form_id = self.form_id
self.helper.form_class = self.classes
self.helper.form_method = self.method
self.helper.form_error_title = self.error_title
self.helper.attrs = self.attrs
if self.switches:
# Get a list of all fields with their location within the layout
layout_field_names = self.helper.layout.get_field_names()
# Transform checkbox fields to switches element
for pointer in layout_field_names:
if isinstance(self.fields[pointer[1]].widget,
forms.CheckboxInput):
field = InlineSwitchField(pointer[1],
switch_class="inline")
self.replace_layout_object(pointer[0], field)
if self.submit:
if isinstance(self.submit, Submit):
self.helper.add_input(self.submit)
elif isinstance(self.submit, str):
self.helper.add_input(Submit('submit', self.submit))
else:
self.helper.add_input(Submit('submit', _("Submit")))
def replace_layout_object(self, position, instead):
previous_layout_object = None
layout_object = self.helper.layout.fields[position[0]]
for i in position[1:]:
previous_layout_object = layout_object
layout_object = layout_object.fields[i]
if previous_layout_object:
previous_layout_object[-1] = instead
else:
self.helper.layout.fields[position[0]] = instead
class FoundationForm(FoundationFormMixin, forms.Form):
"""
A **Django form** that inherit from ``FoundationFormMixin`` to
automatically build a form layout
Example:
.. code-block:: python
from django import forms
from crispy_forms_foundation.forms import FoundationForm
class YourForm(FoundationForm):
title = "Testing"
action = 'test'
layout = Layout(Fieldset("Section", "my_field", "my_field_2"))
switches = False
attrs = {'data_abide': ""}
title = forms.CharField(label='Title', required=True)
slug = forms.CharField(label='Slug', required=False)
"""
def __init__(self, *args, **kwargs):
super(FoundationForm, self).__init__(*args, **kwargs)
self.init_helper()
class FoundationModelForm(FoundationFormMixin, forms.ModelForm):
"""
A **Django Model form** that inherit from ``FoundationFormMixin`` to
automatically build a form layout
Example:
.. code-block:: python
from crispy_forms_foundation.forms import FoundationModelForm
class YourForm(FoundationModelForm):
title = "Testing"
action = 'test'
layout = Layout(Fieldset("Section", "my_field", "my_field_2"))
switches = False
attrs = {'data_abide': ""}
class Meta:
model = MyModel
fields = ['my_field', 'my_field_2', 'my_field_3']
"""
def __init__(self, *args, **kwargs):
super(FoundationModelForm, self).__init__(*args, **kwargs)
self.init_helper()
python-django-crispy-forms-foundation-1.1.0/crispy_forms_foundation/layout/ 0000775 0000000 0000000 00000000000 15035575614 0027366 5 ustar 00root root 0000000 0000000 python-django-crispy-forms-foundation-1.1.0/crispy_forms_foundation/layout/__init__.py 0000664 0000000 0000000 00000002774 15035575614 0031511 0 ustar 00root root 0000000 0000000 """
Layout items for Foundation components.
Inherits from the default **crispy_forms** layout objects to force templates on
the right ``TEMPLATE_PACK`` (defined from ``settings.CRISPY_TEMPLATE_PACK``)
and implements Foundation components.
"""
from .base import Div, Callout, Layout, UneditableField, HTML
from .grid import Row, RowFluid, Column
from .fields import ( # noqa: F401
MultiWidgetField, Field, MultiField,
SplitDateTimeField, InlineField,
InlineJustifiedField, SwitchField,
InlineSwitchField, FakeField, Hidden
)
from .buttons import ( # noqa: F401
ButtonHolder, ButtonHolderCallout, ButtonGroup,
Button, Submit, Reset,
InputButton, InputSubmit, InputReset,
ButtonElement, ButtonSubmit, ButtonReset
)
from .containers import ( # noqa: F401
Container, ContainerHolder,
Fieldset, TabItem, TabHolder,
VerticalTabHolder, AccordionItem,
AccordionHolder
)
__all__ = [
'Div', 'Callout', 'Layout', 'UneditableField', 'HTML',
'Row', 'RowFluid', 'Column',
'Field', 'FakeField', 'Hidden',
'MultiWidgetField', 'MultiField',
'SplitDateTimeField',
'InlineField', 'InlineJustifiedField', 'SwitchField', 'InlineSwitchField',
'ButtonHolder', 'ButtonHolderCallout', 'ButtonGroup',
'Button', 'Submit', 'Reset',
'InputButton', 'InputSubmit', 'InputReset',
'ButtonElement', 'ButtonSubmit', 'ButtonReset',
'Container', 'ContainerHolder', 'Fieldset',
'TabItem', 'TabHolder', 'VerticalTabHolder',
'AccordionItem', 'AccordionHolder',
]
python-django-crispy-forms-foundation-1.1.0/crispy_forms_foundation/layout/base.py 0000664 0000000 0000000 00000002306 15035575614 0030653 0 ustar 00root root 0000000 0000000 """
References:
* `Foundation 6 Callout