crispy-forms-foundation-0.8.0/ 0000755 0001750 0001750 00000000000 13661262315 016205 5 ustar carsten carsten crispy-forms-foundation-0.8.0/MANIFEST.in 0000644 0001750 0001750 00000000724 13661262315 017746 0 ustar carsten carsten 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] crispy-forms-foundation-0.8.0/setup.py 0000644 0001750 0001750 00000000124 13661262315 017714 0 ustar carsten carsten #!/usr/bin/env python # -*- coding: utf-8 -*- from setuptools import setup setup() crispy-forms-foundation-0.8.0/LICENCE.txt 0000644 0001750 0001750 00000002040 13661262315 020004 0 ustar carsten carsten Copyright (c) 2012 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. crispy-forms-foundation-0.8.0/tests/ 0000755 0001750 0001750 00000000000 13661262315 017347 5 ustar carsten carsten crispy-forms-foundation-0.8.0/tests/004_buttons.py 0000644 0001750 0001750 00000003143 13661262315 022003 0 ustar carsten carsten import os import pytest from django.test.html import parse_html from crispy_forms_foundation.layout import (Layout, ButtonGroup, Submit, Button, ButtonElement, ButtonSubmit) from tests.forms import BasicInputForm #from tests.utils import write_output def test_buttongroup(output_test_path, render_output, rendered_template, helper, client): form = BasicInputForm() pack = helper.template_pack helper.layout = Layout( 'simple', ButtonGroup( Submit('Save', 'Save'), Button('Cancel', 'Cancel'), ) ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_buttongroup.html")) #write_output(output_test_path, pack, "test_buttongroup.html", rendered) assert parse_html(attempted) == parse_html(rendered) def test_buttonelement(output_test_path, render_output, rendered_template, helper, client): form = BasicInputForm() pack = helper.template_pack helper.layout = Layout( ButtonSubmit('Save', 'Save'), ButtonElement('Foo', 'Foo', content="""<Pong/>"""), ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_buttonelement.html")) #write_output(output_test_path, pack, "test_buttonelement.html", rendered) assert attempted == rendered crispy-forms-foundation-0.8.0/tests/005_containers.py 0000644 0001750 0001750 00000003404 13661262315 022453 0 ustar carsten carsten import os import pytest from django.test.html import parse_html from crispy_forms_foundation.layout import (Layout, TabHolder, TabItem, AccordionHolder, AccordionItem) from tests.forms import AdvancedForm #from tests.utils import write_output def test_tab(output_test_path, render_output, rendered_template, helper, client): form = AdvancedForm() pack = helper.template_pack helper.layout = Layout( TabHolder( TabItem('My tab 1', 'simple'), TabItem('My tab 2', 'opt_in'), TabItem('My tab 3', 'longtext'), css_id="meep-meep" ) ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_tab.html")) #write_output(output_test_path, pack, "test_tab.html", rendered) assert parse_html(attempted) == parse_html(rendered) def test_accordion(output_test_path, render_output, rendered_template, helper, client): form = AdvancedForm() pack = helper.template_pack # Define 'css_id' to avoid test fails with automatic generated random ID helper.layout = Layout( AccordionHolder( AccordionItem('Group 1', 'simple'), AccordionItem('Group 2', 'opt_in'), AccordionItem('Group 3', 'longtext'), css_id="meep-meep" ) ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_accordion.html")) #write_output(output_test_path, pack, "test_accordion.html", rendered) assert parse_html(attempted) == parse_html(rendered) crispy-forms-foundation-0.8.0/tests/__init__.py 0000644 0001750 0001750 00000000000 13661262315 021446 0 ustar carsten carsten crispy-forms-foundation-0.8.0/tests/utils.py 0000644 0001750 0001750 00000004777 13661262315 021100 0 ustar carsten carsten import os import io from django.template import Context, Template import django from distutils.version import LooseVersion # Getting Django versions compatibilities DJANGO110_COMPAT = LooseVersion(django.get_version()) >= LooseVersion('1.10') def write_output(filepath, pack, filename, content): """ Write content to filepath+pack+filename, create filepath if it does not allready exists. This an helper to automatically rewrite HTML outputs when needed during development. Beware, using this will lose every templating instructions previously written in output attempts. """ if (filepath and filepath != '.' and not os.path.exists(os.path.join(filepath, pack))): os.makedirs(os.path.join(filepath, pack)) destination = os.path.join(filepath, pack, filename) with io.open(destination, 'w', encoding='utf-8') as f: f.write(content) return destination def render_attempted_output(path, **kwargs): """ Return compiled template from given path with given context It's a little hack to be able to use Django template stuff to conditionnate some HTML differences on Django versions. Template is readed as a simple file without using Django template engine loader select. Template context will contains some variables about Django versions compatibilities. Actually this is only about the 'required' input attribute behavior that is different from 1.9 (``required=""``) to 1.10 (``required``). """ context_kwargs = { 'DJANGO110_COMPAT': DJANGO110_COMPAT, } context_kwargs.update(**kwargs) context = Context(context_kwargs) with io.open(path, 'r', encoding='utf-8') as f: template = Template(f.read()) return template.render(context) def get_rendered_template(form, **kwargs): """ Return compiled template with given context where only 'form' is required. If crispy helper is given, it must be given as 'helper' named argument. Template is different depending helper is given or not in kwargs. """ context_kwargs = { "form": form, } context_kwargs.update(**kwargs) context = Context(context_kwargs) # Use spaceless to avoid too much unuseful white spaces tpl = """{% spaceless %}{% load crispy_forms_tags %}""" if 'helper' in kwargs: tpl += """{% crispy form helper %}""" else: tpl += """{% crispy form %}""" tpl += """{% endspaceless %}""" template = Template(tpl) return template.render(context) crispy-forms-foundation-0.8.0/tests/conftest.py 0000644 0001750 0001750 00000001675 13661262315 021557 0 ustar carsten carsten """ Some fixture methods """ import os import pytest from crispy_forms.helper import FormHelper from tests.utils import get_rendered_template, render_attempted_output @pytest.fixture(scope='session') def output_test_path(pytestconfig): """Return absolute path to test outputs directory""" return os.path.join(pytestconfig.rootdir.strpath, 'tests', 'output') @pytest.fixture(scope='session') def rendered_template(): """ Return callable function to render form template """ return get_rendered_template @pytest.fixture(scope='session') def render_output(): """ Return callable function to render output template """ return render_attempted_output @pytest.fixture(scope='function', params=[ "foundation-6" ]) def helper(request): """ Parametrized fixture to return helper configured for a template pack """ helper = FormHelper() helper.template_pack = request.param return helper crispy-forms-foundation-0.8.0/tests/forms.py 0000644 0001750 0001750 00000003461 13661262315 021053 0 ustar carsten carsten """ Used forms in tests """ from django import forms from crispy_forms.helper import FormHelper from crispy_forms_foundation.layout import (Layout, Row, Column, ButtonHolder, Submit) class BasicInputForm(forms.Form): """ Basic form with a single CharField field """ simple = forms.CharField(label='Simple text', widget=forms.TextInput(attrs={'required':''}), required=True) def save(self, commit=True): return class BoolInputForm(forms.Form): """ Basic form with a single BooleanField field """ opt_in = forms.BooleanField( label="Opt in", widget=forms.CheckboxInput(attrs={'required': ''}), required=True) def save(self, commit=True): return class BasicInputFormLayoutIncluded(BasicInputForm): """ Basic form with included layout """ def __init__(self, *args, **kwargs): self.helper = kwargs.pop('helper', FormHelper()) self.helper.form_action = '.' self.helper.layout = Layout( 'simple', ) super(BasicInputFormLayoutIncluded, self).__init__(*args, **kwargs) class AdvancedForm(forms.Form): """ Form with an advanced layout with some inputs """ simple = forms.CharField(label='Simple text', widget=forms.TextInput(attrs={'required':''}), required=True) opt_in = forms.BooleanField( label="Opt in", widget=forms.CheckboxInput(attrs={'required': ''}), required=True) longtext = forms.CharField(label='Address', required=False, widget=forms.Textarea(attrs={'rows': 3})) def save(self, commit=True): return crispy-forms-foundation-0.8.0/tests/003_fields.py 0000644 0001750 0001750 00000004310 13661262315 021547 0 ustar carsten carsten import os import pytest from django.test.html import parse_html from crispy_forms_foundation.layout import (Layout, InlineField, InlineSwitchField, FakeField) from tests.forms import BasicInputForm, BoolInputForm #from tests.utils import write_output def test_fakefield(output_test_path, render_output, rendered_template, helper, client): form = BasicInputForm() pack = helper.template_pack helper.layout = Layout( FakeField('simple') ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_fakefield.html")) #write_output(output_test_path, pack, "test_fakefield.html", rendered) assert parse_html(attempted) == parse_html(rendered) def test_inlinefield(output_test_path, render_output, rendered_template, helper, client): form = BasicInputForm() pack = helper.template_pack helper.layout = Layout( InlineField('simple', label_column='large-7', input_column='large-5', label_class='foobar') ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_inlinefield.html")) #write_output(output_test_path, pack, "test_inlinefield.html", rendered) assert parse_html(attempted) == parse_html(rendered) def test_inlineswitchfield(output_test_path, render_output, rendered_template, helper, client): form = BoolInputForm() pack = helper.template_pack helper.layout = Layout( InlineSwitchField('opt_in', label_column='large-8', input_column='large-4', label_class='foobar', switch_class="inline") ) rendered = rendered_template(form, helper=helper) attempted = render_output(os.path.join(output_test_path, pack, "test_inlineswitchfield.html")) #write_output(output_test_path, pack, "test_inlineswitchfield.html", rendered) assert parse_html(attempted) == parse_html(rendered) crispy-forms-foundation-0.8.0/tests/output/ 0000755 0001750 0001750 00000000000 13661262315 020707 5 ustar carsten carsten crispy-forms-foundation-0.8.0/tests/output/foundation-6/ 0000755 0001750 0001750 00000000000 13661262315 023220 5 ustar carsten carsten crispy-forms-foundation-0.8.0/tests/output/foundation-6/test_advanced.html 0000644 0001750 0001750 00000002324 13661262315 026713 0 ustar carsten carsten