Skip to content

Commit

Permalink
Merge pull request #45 from sveetch/mpasternak-master
Browse files Browse the repository at this point in the history
Django 3 + Python 3.6 support, drop deprecated Django, crispy-forms and Foundation supports
  • Loading branch information
sveetch authored May 20, 2020
2 parents 6be3799 + e4d7d82 commit 8eb6ac7
Show file tree
Hide file tree
Showing 71 changed files with 85 additions and 1,126 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ flake:
.PHONY: flake

tests:
$(PYTEST) -vv --exitfirst tests/
$(PYTEST) -vv tests/
.PHONY: tests

quality: tests flake
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.. _Django: https://www.djangoproject.com/
.. _django-crispy-forms: https://github.com/maraujop/django-crispy-forms
.. _Foundation for sites: http://foundation.zurb.com/
.. _Python: http://python.org/

Introduction
============
Expand All @@ -19,6 +20,7 @@ Links
Requires
========

* `Django`_ >=1.8;
* `django-crispy-forms`_ >= 1.6.x;
* `Python`_ >= 3.5;
* `Django`_ >= 2.0;
* `django-crispy-forms`_ >= 1.8.1;
* `Foundation for sites`_ >= 6.3.x;
9 changes: 2 additions & 7 deletions crispy_forms_foundation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

from django import forms
from django.forms.fields import FileField, ImageField
from django.utils.translation import ugettext_lazy as _
try:
# Default 'reverse' path since Django1.10
from django.urls import reverse, NoReverseMatch
except ImportError:
# 'reverse' path for Django<1.10
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.translation import gettext_lazy as _
from django.urls import reverse, NoReverseMatch

from crispy_forms.helper import FormHelper

Expand Down
8 changes: 4 additions & 4 deletions crispy_forms_foundation/layout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from __future__ import absolute_import

from .base import Div, Panel, Callout, Layout, UneditableField, HTML
from .base import Div, Callout, Layout, UneditableField, HTML
from .grid import Row, RowFluid, Column

from .fields import ( # noqa: F401
Expand All @@ -17,7 +17,7 @@
InlineSwitchField, FakeField, Hidden
)
from .buttons import ( # noqa: F401
ButtonHolder, ButtonHolderPanel, ButtonGroup,
ButtonHolder, ButtonHolderCallout, ButtonGroup,
Button, Submit, Reset,
InputButton, InputSubmit, InputReset,
ButtonElement, ButtonSubmit, ButtonReset
Expand All @@ -31,15 +31,15 @@


__all__ = [
'Div', 'Panel', 'Callout', 'Layout', 'UneditableField', 'HTML',
'Div', 'Callout', 'Layout', 'UneditableField', 'HTML',
'Row', 'RowFluid', 'Column',

'Field', 'FakeField', 'Hidden',
'MultiWidgetField', 'MultiField',
'SplitDateTimeField',
'InlineField', 'InlineJustifiedField', 'SwitchField', 'InlineSwitchField'

'ButtonHolder', 'ButtonHolderPanel', 'ButtonGroup',
'ButtonHolder', 'ButtonHolderCallout', 'ButtonGroup',
'Button', 'Submit', 'Reset',
'InputButton', 'InputSubmit', 'InputReset',
'ButtonElement', 'ButtonSubmit', 'ButtonReset',
Expand Down
25 changes: 1 addition & 24 deletions crispy_forms_foundation/layout/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
==============
.. _Foundation: http://github.com/zurb/foundation
.. _Foundation 5 Panel: http://foundation.zurb.com/sites/docs/v/5.5.3/components/panels.html
.. _Foundation 6 Callout: http://foundation.zurb.com/sites/docs/callout.html
References:
* `Foundation 5 Panel`_;
* `Foundation 6 Callout`_;
""" # noqa: E501
Expand All @@ -17,7 +15,7 @@
__all__ = [
'Layout', 'UneditableField',
'HTML', 'Div',
'Panel', 'Callout',
'Callout',
]


Expand Down Expand Up @@ -50,31 +48,10 @@ class names.
template = "%s/layout/div.html"


class Panel(crispy_forms_layout.Div):
"""
Act like ``Div`` but add a ``panel`` class name.
``Panel`` component has been replaced with the ``Callout`` in Foundation-6.
Example:
.. sourcecode:: python
Panel('form_field_1', 'form_field_2', css_id='div-example',
css_class='divs')
"""
def __init__(self, field, *args, **kwargs):
kwargs['css_class'] = kwargs.get('css_class', '')+' panel'
super(Panel, self).__init__(field, *args, **kwargs)


class Callout(crispy_forms_layout.Div):
"""
Act like ``Div`` but add a ``callout`` class name.
``Callout`` component is the Foundation-6 replacement of ``Panel``
component.
Example:
.. sourcecode:: python
Expand Down
16 changes: 2 additions & 14 deletions crispy_forms_foundation/layout/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
.. _Foundation: http://github.com/zurb/foundation
References
* `Foundation 5 Button <http://foundation.zurb.com/sites/docs/v/5.5.3/components/buttons.html>`_;
* `Foundation 5 Button Group <http://foundation.zurb.com/sites/docs/v/5.5.3/components/button_groups.html>`_;
* `Foundation 6 Button <http://foundation.zurb.com/sites/docs/button.html>`_;
* `Foundation 6 Button Group <http://foundation.zurb.com/sites/docs/button-group.html>`_;
Expand All @@ -18,7 +16,7 @@


__all__ = [
'ButtonHolder', 'ButtonHolderPanel', 'ButtonHolderCallout', 'ButtonGroup',
'ButtonHolder', 'ButtonHolderCallout', 'ButtonGroup',
'Button', 'Submit', 'Reset',
'InputButton', 'InputSubmit', 'InputReset',
'ButtonElement', 'ButtonSubmit', 'ButtonReset',
Expand All @@ -45,24 +43,14 @@ class ButtonHolder(crispy_forms_layout.ButtonHolder):
template = "%s/layout/buttonholder.html"


class ButtonHolderPanel(ButtonHolder):
"""
Act like ``ButtonHolder`` but add a ``panel`` class name on the main
``div``.
"""
def __init__(self, field, *args, **kwargs):
kwargs['css_class'] = kwargs.get('css_class', '')+' panel'
super(ButtonHolderPanel, self).__init__(field, *args, **kwargs)


class ButtonHolderCallout(ButtonHolder):
"""
Act like ``ButtonHolder`` but add a ``callout`` class name on the main
``div``.
"""
def __init__(self, field, *args, **kwargs):
kwargs['css_class'] = kwargs.get('css_class', '')+' callout'
super(ButtonHolderPanel, self).__init__(field, *args, **kwargs)
super().__init__(field, *args, **kwargs)


class ButtonGroup(crispy_forms_layout.LayoutObject):
Expand Down
9 changes: 2 additions & 7 deletions crispy_forms_foundation/layout/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
.. _Abide: http://foundation.zurb.com/docs/components/abide.html
References
* `Foundation 5 fieldset <http://foundation.zurb.com/sites/docs/v/5.5.3/components/forms.html>`_;
* `Foundation 5 Accordion <http://foundation.zurb.com/sites/docs/v/5.5.3/components/accordion.html>`_;
* `Foundation 5 Tabs <http://foundation.zurb.com/sites/docs/v/5.5.3/components/tabs.html>`_;
* `Foundation 6 fieldset <http://foundation.zurb.com/sites/docs/forms.html#fieldset-styles>`_;
* `Foundation 6 Accordion <http://foundation.zurb.com/sites/docs/accordion.html>`_;
* `Foundation 6 Tabs <http://foundation.zurb.com/sites/docs/tabs.html>`_;
Expand All @@ -23,7 +20,6 @@
from crispy_forms import layout as crispy_forms_layout
from crispy_forms.utils import render_field, TEMPLATE_PACK
from crispy_forms import bootstrap as crispy_forms_bootstrap
from crispy_forms.compatibility import text_type


__all__ = [
Expand Down Expand Up @@ -119,8 +115,7 @@ def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
# accordion group needs the parent div id to set `data-parent` (I don't
# know why). This needs to be a unique id
if not self.css_id:
self.css_id = "-".join(["tabsholder",
text_type(randint(1000, 9999))])
self.css_id = "-".join(["tabsholder", str(randint(1000, 9999))])

for tab in self.fields:
tab.active = False
Expand Down Expand Up @@ -225,7 +220,7 @@ def render(self, form, form_style, context, template_pack=TEMPLATE_PACK,
# know why). This needs to be a unique id
if not self.css_id:
self.css_id = "-".join(["accordion",
text_type(randint(1000, 9999))])
str(randint(1000, 9999))])

# Active first 'AccordionItem' containing a field error if any, else
# active first holder item
Expand Down
2 changes: 0 additions & 2 deletions crispy_forms_foundation/layout/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
.. _Abide: http://foundation.zurb.com/docs/components/abide.html
References
* `Foundation 5 Forms <http://foundation.zurb.com/sites/docs/v/5.5.3/components/forms.html>`_;
* `Foundation 5 Switches <http://foundation.zurb.com/sites/docs/v/5.5.3/components/switch.html>`_;
* `Foundation 6 Forms <http://foundation.zurb.com/sites/docs/forms.html>`_;
* `Foundation 6 Switches <http://foundation.zurb.com/sites/docs/switch.html>`_;
Expand Down
1 change: 0 additions & 1 deletion crispy_forms_foundation/layout/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
.. _Abide: http://foundation.zurb.com/docs/components/abide.html
References
* `Foundation 5 Grid <http://foundation.zurb.com/sites/docs/v/5.5.3/components/grid.html>`_;
* `Foundation 6 Grid <http://foundation.zurb.com/sites/docs/grid.html>`_;
""" # noqa: E501
Expand Down
6 changes: 2 additions & 4 deletions crispy_forms_foundation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
# Allowed layout pack
CRISPY_ALLOWED_TEMPLATE_PACKS = (
'bootstrap',
'uni_form',
'bootstrap3',
'bootstrap4',
'foundation-5',
'foundation-6'
'foundation-6',
'uni_form',
)


Expand Down
22 changes: 0 additions & 22 deletions crispy_forms_foundation/templates/foundation-5/betterform.html

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions crispy_forms_foundation/templates/foundation-5/errors.html

This file was deleted.

14 changes: 0 additions & 14 deletions crispy_forms_foundation/templates/foundation-5/errors_formset.html

This file was deleted.

44 changes: 0 additions & 44 deletions crispy_forms_foundation/templates/foundation-5/field.html

This file was deleted.

32 changes: 0 additions & 32 deletions crispy_forms_foundation/templates/foundation-5/field.strict.html

This file was deleted.

Loading

0 comments on commit 8eb6ac7

Please sign in to comment.