Skip to content

Rename tbx template pack to tbxforms #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

### Changed

- Renamed `tbx` template directory and crispy forms template pack to `tbxforms` [#92]

### Fixed

- Conditional fields not working properly when there are multiple elements inspecting the same driving field [#91]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ INSTALLED_APPS = [
Now add the following settings to tell `django-crispy-forms` to use `tbxforms`:

```python
CRISPY_ALLOWED_TEMPLATE_PACKS = ["tbx"]
CRISPY_TEMPLATE_PACK = "tbx"
CRISPY_ALLOWED_TEMPLATE_PACKS = ["tbxforms"]
CRISPY_TEMPLATE_PACK = "tbxforms"
```

### Install the NPM package
Expand Down
3 changes: 0 additions & 3 deletions tbxforms/templates/tbx/inputs.html

This file was deleted.

2 changes: 0 additions & 2 deletions tbxforms/templates/tbx/layout/help_text_and_errors.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if form.form_html %}
{% if include_media %}{{ form.media }}{% endif %}
{% include "tbx/errors.html" %}
{% include "tbxforms/errors.html" %}
{{ form.form_html }}
{% else %}
{% include "tbx/uni_form.html" %}
{% include "tbxforms/uni_form.html" %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="tbxforms-form-group{% if field.errors %} tbxforms-form-group--error{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">

{% if field|is_checkboxes %}
{% include "tbx/layout/checkboxes.html" %}
{% include "tbxforms/layout/checkboxes.html" %}
{% endif %}

{% if field|is_radios %}
{% include "tbx/layout/radios.html" %}
{% include "tbxforms/layout/radios.html" %}
{% endif %}

{% if field|is_multivalue %}
{% include "tbx/layout/multifield.html" %}
{% include "tbxforms/layout/multifield.html" %}
{% endif %}

{% if not field|is_checkboxes and not field|is_radios and not field|is_multivalue %}
Expand All @@ -36,7 +36,7 @@
{% endif %}

{% if field|is_checkbox and form_show_labels %}
{% include "tbx/layout/help_text_and_errors.html" %}
{% include "tbxforms/layout/help_text_and_errors.html" %}
<div class="tbxforms-checkboxes{% if checkboxes_small %} tbxforms-checkboxes--small{% endif %}">
<div class="tbxforms-checkboxes__item">
{% crispy_tbx_field field %}
Expand All @@ -46,7 +46,7 @@
</div>
</div>
{% else %}
{% include "tbx/layout/help_text_and_errors.html" %}
{% include "tbxforms/layout/help_text_and_errors.html" %}
{% crispy_tbx_field field %}
{% if max_characters or max_words %}
<p id="{{ field.id_for_label }}-info" class="tbxforms-hint tbxforms-character-count__message" aria-live="polite">
Expand Down
3 changes: 3 additions & 0 deletions tbxforms/templates/tbxforms/inputs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for input in inputs %}
{% include "tbxforms/layout/baseinput.html" %}
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</legend>
{% endif %}

{% include "tbx/layout/help_text_and_errors.html" %}
{% include "tbxforms/layout/help_text_and_errors.html" %}

<div class="tbxforms-checkboxes{% if inline %}--inline{% endif %}{% if checkboxes_small %} tbxforms-checkboxes--small{% endif %}">
{% for choice in field.field.choices %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% include "tbxforms/layout/help_text.html" %}
{% include "tbxforms/layout/field_errors.html" %}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</legend>
{% endif %}

{% include "tbx/layout/help_text_and_errors.html" %}
{% include "tbxforms/layout/help_text_and_errors.html" %}
{% crispy_tbx_field field %}

</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</legend>
{% endif %}

{% include "tbx/layout/help_text_and_errors.html" %}
{% include "tbxforms/layout/help_text_and_errors.html" %}

<div class="tbxforms-radios{% if radios_inline %}--inline{% endif %}{% if radios_small %} tbxforms-radios--small{% endif %}">
{% for choice in field.field.choices %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% if include_media %}{{ form.media }}{% endif %}

{% include "tbx/errors.html" %}
{% include "tbxforms/errors.html" %}

{% for field in form %}
{% include field_template %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% with formset.management_form as form %}
{% include "tbx/uni_form.html" %}
{% include "tbxforms/uni_form.html" %}
{% endwith %}

{% for form in formset %}
<div class="multiField">
{% include "tbx/uni_form.html" %}
{% include "tbxforms/uni_form.html" %}
</div>
{% endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
{% csrf_token %}
{% endif %}

{% include "tbx/display_form.html" %}
{% include "tbxforms/display_form.html" %}

{% include "tbx/inputs.html" %}
{% include "tbxforms/inputs.html" %}

{% if form_tag %}
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</div>

{% for form in formset %}
{% include "tbx/display_form.html" %}
{% include "tbxforms/display_form.html" %}
{% endfor %}

{% if inputs %}
<div class="form-actions">
{% for input in inputs %}
{% include "tbx/layout/baseinput.html" %}
{% include "tbxforms/layout/baseinput.html" %}
{% endfor %}
</div>
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions tbxforms/templatetags/tbxforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def render(self, context): # noqa: C901
[getattr(field.field.widget, "widget", field.field.widget)],
)

if template_pack == "tbx":
if template_pack == "tbxforms":
if is_multivalue(field):
error_widgets = [field.widget for field in field.field.fields]
error_count = sum(
Expand Down Expand Up @@ -215,7 +215,7 @@ def render(self, context): # noqa: C901

css_class = " ".join(css_class)

if template_pack == "tbx":
if template_pack == "tbxforms":
# The ability to override input_type was added to
# avoid having to create new widgets. However, as a
# result, the browser validates the field and displays
Expand Down Expand Up @@ -342,7 +342,7 @@ def crispy_tbx_field(parser, token):
``django-crispy-forms``. Any additions are clearly marked with a
check to see if the 'gds' template pack is being used.
This template tag is only used within the tbx/field.html template
This template tag is only used within the tbxforms/field.html template
and you almost certainly will not have to deal with it, even if
you are laying out a form explicitly.
Expand Down
2 changes: 1 addition & 1 deletion tbxforms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DateInputWidget(forms.MultiWidget):
"""

template_name = "tbx/widgets/date.html"
template_name = "tbxforms/widgets/date.html"

def __init__(self, *args, **kwargs):
widgets = [
Expand Down
2 changes: 1 addition & 1 deletion tests/layout/test_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
),
)
class TestButtons:
TEMPLATE = '{% include "tbx/layout/button.html" %}'
TEMPLATE = '{% include "tbxforms/layout/button.html" %}'

def test_button(self, button_factory, snapshot_html):
button = button_factory("name", "Title")
Expand Down
2 changes: 1 addition & 1 deletion tests/layout/test_escaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TestButtonEscaping:
be marked as safe.
"""

TEMPLATE = '{% include "tbx/layout/button.html" %}'
TEMPLATE = '{% include "tbxforms/layout/button.html" %}'

def test_unsafe_markup_escaped(self, button_factory, snapshot_html):
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
]

CRISPY_ALLOWED_TEMPLATE_PACKS = ("tbx",)
CRISPY_ALLOWED_TEMPLATE_PACKS = ("tbxforms",)

CRISPY_TEMPLATE_PACK = "tbx"
CRISPY_TEMPLATE_PACK = "tbxforms"

CRISPY_FAIL_SILENTLY = False
Loading