Skip to content

Commit

Permalink
Add size parameter to example forms (#77)
Browse files Browse the repository at this point in the history
* Add size parameter to example form
* Set version
  • Loading branch information
dyve committed May 2, 2021
1 parent 6bfbe4e commit 2f21319
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## In development

- Add size parameter to example forms.

## [1.0.0] - 2021-04-30

- Set PyPI classifier for Development Status to Production/Stable.
Expand Down
17 changes: 9 additions & 8 deletions example/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,40 @@ def get_context_data(self, **kwargs):
return context


class LayoutMixin:
class GetParametersMixin:
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["layout"] = self.request.GET.get("layout", "vertical")
context["layout"] = self.request.GET.get("layout", None)
context["size"] = self.request.GET.get("size", None)
return context


class DefaultFormsetView(LayoutMixin, FormView):
class DefaultFormsetView(GetParametersMixin, FormView):
template_name = "app/formset.html"
form_class = ContactFormSet


class DefaultFormView(LayoutMixin, FormView):
class DefaultFormView(GetParametersMixin, FormView):
template_name = "app/form.html"
form_class = ContactForm


class DefaultFormByFieldView(LayoutMixin, FormView):
class DefaultFormByFieldView(GetParametersMixin, FormView):
template_name = "app/form_by_field.html"
form_class = ContactForm


class FormHorizontalView(LayoutMixin, FormView):
class FormHorizontalView(GetParametersMixin, FormView):
template_name = "app/form_horizontal.html"
form_class = ContactForm


class FormInlineView(LayoutMixin, FormView):
class FormInlineView(GetParametersMixin, FormView):
template_name = "app/form_inline.html"
form_class = ContactForm


class FormWithFilesView(LayoutMixin, FormView):
class FormWithFilesView(GetParametersMixin, FormView):
template_name = "app/form_with_files.html"
form_class = FilesForm

Expand Down
2 changes: 1 addition & 1 deletion example/templates/app/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<form method="post">
{% csrf_token %}

{% bootstrap_form form layout=layout %}
{% bootstrap_form form layout=layout size=size %}

{% bootstrap_button button_type="submit" content="OK" %}
{% bootstrap_button button_type="reset" content="Cancel" %}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
setup(
name="django-bootstrap5",
zip_safe=False,
version="1.0.0",
version="1.1.0dev",
description="Bootstrap 5 for Django",
long_description=README,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 2f21319

Please sign in to comment.