-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from jeromelebleu/bootstrap5
Add a mixin for Bootstrap v5
- Loading branch information
Showing
23 changed files
with
244 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% load tapeforms %}<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Simple Bootstrap v5</title> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> | ||
</head> | ||
|
||
<body> | ||
<div class="p-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">My form</h5> | ||
<form action="." method="post" novalidate> | ||
{% csrf_token %} | ||
{% form form %} | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
from django import forms | ||
|
||
from tapeforms.contrib.bootstrap import BootstrapTapeformMixin | ||
from tapeforms.contrib.bootstrap import ( | ||
Bootstrap4TapeformMixin, | ||
Bootstrap5TapeformMixin, | ||
BootstrapTapeformMixin, | ||
) | ||
|
||
from . import FormFieldsSnapshotTestMixin | ||
|
||
|
||
class DummyForm(BootstrapTapeformMixin, forms.Form): | ||
CHOICES = (('foo', 'Foo'), ('bar', 'Bar')) | ||
|
||
|
||
class DummyBaseForm(forms.Form): | ||
text = forms.CharField() | ||
checkbox = forms.BooleanField() | ||
clearable_file = forms.FileField(required=False) | ||
radio_buttons = forms.MultipleChoiceField( | ||
choices=(('foo', 'foo'), ('bar', 'bar'), ('baz', 'bar')), widget=forms.RadioSelect | ||
) | ||
radio_select = forms.MultipleChoiceField(choices=CHOICES, widget=forms.RadioSelect) | ||
|
||
|
||
class Dummy4Form(Bootstrap4TapeformMixin, DummyBaseForm): | ||
pass | ||
|
||
|
||
class Dummy5Form(Bootstrap5TapeformMixin, DummyBaseForm): | ||
select = forms.ChoiceField(choices=CHOICES) | ||
select_multiple = forms.MultipleChoiceField(choices=CHOICES) | ||
|
||
class TestBootstrapTapeformMixin(FormFieldsSnapshotTestMixin): | ||
form_class = DummyForm | ||
snapshot_dir = 'bootstrap' | ||
|
||
def test_compatibility_mixin(): | ||
assert BootstrapTapeformMixin == Bootstrap4TapeformMixin | ||
|
||
|
||
class TestBootstrap4TapeformMixin(FormFieldsSnapshotTestMixin): | ||
form_class = Dummy4Form | ||
snapshot_dir = 'bootstrap4' | ||
|
||
def test_apply_widget_invalid_options(self): | ||
form = DummyForm({}) | ||
form = self.form_class({}) | ||
assert 'text' in form.errors | ||
widget = form.fields['text'].widget | ||
assert sorted(widget.attrs['class'].split(' ')) == ['form-control', 'is-invalid'] | ||
|
||
|
||
class TestBootstrap5TapeformMixin(FormFieldsSnapshotTestMixin): | ||
form_class = Dummy5Form | ||
snapshot_dir = 'bootstrap5' |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.