Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use django-bootstrap3 instead of our own code

Patryk Zawadzki32cf0ba23139
diff --git a/requirements.in b/requirements.in
index 8c68de0cbf..4c59fbc55a 100644
--- a/requirements.in
+++ b/requirements.in
@@ -3,6 +3,7 @@ BabelDjango>=0.2
Django>=1.8,!=1.8.6
dj_database_url>=0.3.0
dj_email_url>=0.0.4
+django-bootstrap3>=6.2.0
django-cache-url>=1.0.0
django-countries>=3.4
django-emailit>=0.2.2
diff --git a/requirements.txt b/requirements.txt
index 61ce757a9d..edf08f3afd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -15,6 +15,7 @@ cssutils==1.0.1 # via premailer
dj-database-url==0.3.0
dj-email-url==0.0.4
django-absolute==0.3 # via django-emailit
+django-bootstrap3==6.2.2
django-cache-url==1.0.0
django-countries==3.4.1
django-emailit==0.2.2
diff --git a/saleor/cart/templates/cart/index.html b/saleor/cart/templates/cart/index.html
index ca86ab5654..35aa695fe3 100644
--- a/saleor/cart/templates/cart/index.html
+++ b/saleor/cart/templates/cart/index.html
@@ -1,5 +1,4 @@
{% extends "base.html" %}
-{% load as_vertical_form from bootstrap %}
{% load gross from prices_i18n %}
{% load i18n %}
{% load staticfiles %}
diff --git a/saleor/checkout/templates/checkout/address_form.html b/saleor/checkout/templates/checkout/address_form.html
deleted file mode 100644
index d62545ad35..0000000000
--- a/saleor/checkout/templates/checkout/address_form.html
+++ /dev/null
@@ -1,92 +0,0 @@
-{% load i18n %}
-{% load static from staticfiles %}
-{% load as_vertical_form from bootstrap %}
-
-
-{% with field=addresses_form.address %}
- {% if field.is_hidden %}
- {{ field }}
- {% else %}
- <div class="row">
- <div class="btn-group-vertical col-sm-12" data-toggle="buttons">
- {% if step.shipping_address %}
- <label for="{{ field.html_name }}_copy" class="btn btn-default{% if field.value == field.field.copy_choice_value %} active{% endif %}">
- <input type="radio"
- name="{{ field.html_name }}"
- value="{{ field.field.copy_choice_value }}"
- id="{{ field.html_name }}_copy"
- {% if field.value == field.field.copy_choice_value %}checked{% endif %}>
- {{ field.field.copy_choice_label }}
- </label>
- {% endif %}
-
- {% if addresses %}
- {% for address in addresses %}
- <label for="{{ field.html_name }}_{{ address.id }}" class="btn btn-default{% if field.value == address.id %} active{% endif %}">
- <input type="radio"
- name="{{ field.html_name }}"
- value="{{ address.id }}"
- id="{{ field.html_name }}_{{ address.id }}"
- {% if field.value == address.id %}checked{% endif %}>
- {% include "userprofile/snippets/address-details.html" with address=address %}
- </label>
- {% endfor %}
- {% endif %}
-
- {% if step.shipping_address or addresses %}
- <label for="{{ field.html_name }}_new" class="btn btn-default{% if field.value == field.field.new_choice_value %} active{% endif %}">
- <input type="radio"
- name="{{ field.html_name }}"
- value="{{ field.field.new_choice_value }}"
- id="{{ field.html_name }}_new"
- {% if field.value == field.field.new_choice_value %}checked{% endif %}>
- {{ field.field.new_choice_label }}
- </label>
- {% endif %}
- </div>
- </div>
- <br>
- {% endif %}
-{% endwith %}
-<div class="conditional-visibility" data-controller="input[name={{ addresses_form.address.html_name }}]" data-value="{{ addresses_form.address.field.new_choice_value }}">
- {% with new_address=step.forms.new_address %}
- <div class="row">
- <div class="col-sm-6">
- {{ new_address.first_name|as_vertical_form }}
- </div>
- <div class="col-sm-6">
- {{ new_address.last_name|as_vertical_form }}
- </div>
- </div>
- {{ new_address.company_name|as_vertical_form }}
- <div class="row">
- <div class="col-sm-8">
- {{ new_address.street_address_1|as_vertical_form }}
- </div>
- <div class="col-sm-4">
- {{ new_address.street_address_2|as_vertical_form }}
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- {{ new_address.city|as_vertical_form }}
- </div>
- <div class="col-sm-6">
- {{ new_address.city_area|as_vertical_form }}
- </div>
- </div>
- <div class="row">
- <div class="col-sm-8">
- {{ new_address.country_area|as_vertical_form }}
- </div>
- <div class="col-sm-4">
- {{ new_address.postal_code|as_vertical_form }}
- </div>
- </div>
- {{ new_address.country|as_vertical_form }}
- {% if display_email_form %}
- {{ step.forms.email|as_vertical_form }}
- {% endif %}
- {{ new_address.phone|as_vertical_form }}
- {% endwith %}
-</div>
diff --git a/saleor/checkout/templates/checkout/payment.html b/saleor/checkout/templates/checkout/payment.html
index 7f2dff997b..812836ffe9 100644
--- a/saleor/checkout/templates/checkout/payment.html
+++ b/saleor/checkout/templates/checkout/payment.html
@@ -1,6 +1,6 @@
{% extends "checkout/details.html" %}
{% load i18n %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% block forms %}
@@ -8,9 +8,9 @@
{% csrf_token %}
<h4>{% trans "Payment" %}</h4>
<p class="text-right">
- {{ payment_form|as_vertical_form }}
+ {% bootstrap_form payment_form %}
- {{ billing_address_form|as_vertical_form }}
+ {% bootstrap_form billing_address_form %}
<button type="submit" class="btn btn-primary btn-lg">
{% trans "Place order" %}
</button>
diff --git a/saleor/checkout/templates/checkout/shipping_address.html b/saleor/checkout/templates/checkout/shipping_address.html
index 3018eadbf6..b5f6239f95 100644
--- a/saleor/checkout/templates/checkout/shipping_address.html
+++ b/saleor/checkout/templates/checkout/shipping_address.html
@@ -1,6 +1,6 @@
{% extends "checkout/details.html" %}
{% load i18n %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% block steps_menu %}
<ul class="nav nav-pills nav-justified nav-wizard">
@@ -36,7 +36,7 @@
{% if request.user.is_authenticated %}
{% include "checkout/snippets/addresses-form.html" with addresses_form=user_form addresses=additional_addresses address_form=address_form only %}
{% else %}
- {{ user_form|as_vertical_form }}
+ {% bootstrap_form user_form %}
{% include "userprofile/snippets/address-form.html" with address_form=address_form only %}
{% endif %}
diff --git a/saleor/checkout/templates/checkout/shipping_method.html b/saleor/checkout/templates/checkout/shipping_method.html
index ece6f226d8..50e2058082 100644
--- a/saleor/checkout/templates/checkout/shipping_method.html
+++ b/saleor/checkout/templates/checkout/shipping_method.html
@@ -1,8 +1,7 @@
{% extends "checkout/details.html" %}
{% load i18n %}
{% load gross from prices_i18n %}
-
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% block steps_menu %}
@@ -37,7 +36,7 @@
{% csrf_token %}
<h3>{% trans "Shipping method" %}</h3>
- {{ shipping_method_form|as_vertical_form }}
+ {% bootstrap_form shipping_method_form show_label=False %}
<p class="text-right">
<button type="submit" class="btn btn-primary btn-lg">
diff --git a/saleor/checkout/templates/checkout/snippets/addresses-form-panel.html b/saleor/checkout/templates/checkout/snippets/addresses-form-panel.html
index 9324ff3fee..1fb8c74430 100644
--- a/saleor/checkout/templates/checkout/snippets/addresses-form-panel.html
+++ b/saleor/checkout/templates/checkout/snippets/addresses-form-panel.html
@@ -1,5 +1,3 @@
-{% load as_vertical_form from bootstrap %}
-
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="address{{ radio_value }}">
<h4 class="radio panel-title">
diff --git a/saleor/checkout/templates/checkout/summary.html b/saleor/checkout/templates/checkout/summary.html
index 5271bbbb96..772b9217a6 100644
--- a/saleor/checkout/templates/checkout/summary.html
+++ b/saleor/checkout/templates/checkout/summary.html
@@ -1,6 +1,5 @@
{% extends "checkout/details.html" %}
{% load i18n %}
-{% load as_vertical_form from bootstrap %}
{% block steps_menu %}
diff --git a/saleor/checkout/templates/checkout/summary_without_shipping.html b/saleor/checkout/templates/checkout/summary_without_shipping.html
index e935397ac6..8c52005fba 100644
--- a/saleor/checkout/templates/checkout/summary_without_shipping.html
+++ b/saleor/checkout/templates/checkout/summary_without_shipping.html
@@ -1,6 +1,6 @@
{% extends "checkout/details.html" %}
{% load i18n %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% block steps_menu %}{% endblock %}
@@ -13,7 +13,7 @@
{% if request.user.is_authenticated %}
{% include "checkout/snippets/addresses-form.html" with addresses_form=addresses_form addresses=additional_addresses address_form=address_form only %}
{% else %}
- {{ user_form|as_vertical_form }}
+ {% bootstrap_form user_form %}
{% include "userprofile/snippets/address-form.html" with address_form=address_form only %}
{% endif %}
diff --git a/saleor/core/templates/bootstrap/_field_horizontal.html b/saleor/core/templates/bootstrap/_field_horizontal.html
deleted file mode 100644
index 010fb878b7..0000000000
--- a/saleor/core/templates/bootstrap/_field_horizontal.html
+++ /dev/null
@@ -1,46 +0,0 @@
-{% load render_widget from bootstrap %}
-{% if bound_field.is_hidden %}
-{{ bound_field }}
-{% else %}
-<div class="form-group {{ bound_field.html_name }}{% if bound_field.errors %} has-error{% endif %}{% if bound_field.field.required %} required{% endif %}">
- {% if show_label %}
- <label class="col-sm-2 control-label" for="id_{{ bound_field.html_name }}">{{ bound_field.label }}</label>
- {% endif %}
- <div class="col-sm-10{% if not show_label %} col-sm-offset-2{% endif %}">
- {% if input_type == "input" or input_type == "textarea" or input_type == "select" %}
- {% render_widget bound_field class="form-control" %}
- {% endif %}
- {% if input_type == "checkbox" %}
- <label class="checkbox" for="id_{{ bound_field.html_name }}">
- {% render_widget bound_field class="form-control" %}
- {{ bound_field.label }}
- </label>
- {% endif %}
- {% if input_type == "radio" %}
- {% for value, name in bound_field.field.choices %}
- {% if value %}
- <label class="radio" for="id_{{ bound_field.html_name }}_{{ forloop.counter0 }}">
- <input type="radio" value="{{ value }}" name="{{ bound_field.html_name }}" id="id_{{ bound_field.html_name }}_{{ forloop.counter0 }}" class="form-control">
- {{ name }}
- </label>
- {% endif %}
- {% endfor %}
- {% endif %}
- {% if input_type == "multi_widget" %}
- <div class="row">
- {% render_widget bound_field class="form-control" %}
- </div>
- {% endif %}
-
- {% if bound_field.help_text %}
- <span class="help-block">{{ bound_field.help_text }}</span>
- {% endif %}
-
- {% if bound_field.errors %}
- {% for error in bound_field.errors %}
- <span class="label label-danger">{{ error }}</span>
- {% endfor %}
- {% endif %}
- </div>
-</div>
-{% endif %}
diff --git a/saleor/core/templates/bootstrap/_field_vertical.html b/saleor/core/templates/bootstrap/_field_vertical.html
deleted file mode 100644
index 1164b39dc6..0000000000
--- a/saleor/core/templates/bootstrap/_field_vertical.html
+++ /dev/null
@@ -1,48 +0,0 @@
-{% load render_widget from bootstrap %}
-{% if bound_field.is_hidden %}
-{{ bound_field }}
-{% else %}
-<div class="form-group {{ bound_field.html_name }}{% if bound_field.errors %} has-error{% endif %}{% if bound_field.field.required %} required{% endif %}">
- {% if show_label %}
- <label class="control-label" for="id_{{ bound_field.html_name }}">{{ bound_field.label }}</label>
- {% endif %}
- {% if input_type == "input" or input_type == "textarea" or input_type == "select" %}
- {% render_widget bound_field class="form-control" %}
- {% endif %}
- {% if input_type == "checkbox" %}
- <label class="checkbox" for="id_{{ bound_field.html_name }}">
- {% render_widget bound_field class="form-control" %}
- {{ bound_field.label }}
- </label>
- {% endif %}
- {% if input_type == "radio" %}
- <div class="btn-group" data-toggle="buttons">
- {% for value, name in bound_field.field.choices %}
- {% if value %}
- <label for="id_{{ bound_field.html_name }}_{{ forloop.counter0 }}"
- class="btn btn-default{% if forloop.first %} active{% endif %}">
- <input type="radio" value="{{ value }}" id="id_{{ bound_field.html_name }}_{{ forloop.counter0 }}"
- name="{{ bound_field.html_name }}"{% if forloop.first %} checked{% endif %}>
- {{ name }}
- </label>
- {% endif %}
- {% endfor %}
- </div>
- {% endif %}
- {% if input_type == "multi_widget" %}
- <div class="row">
- {% render_widget bound_field class="form-control" %}
- </div>
- {% endif %}
-
- {% if bound_field.help_text %}
- <span class="help-block">{{ bound_field.help_text }}</span>
- {% endif %}
-
- {% if bound_field.errors %}
- {% for error in bound_field.errors %}
- <span class="text-danger">{{ error }}</span>
- {% endfor %}
- {% endif %}
-</div>
-{% endif %}
diff --git a/saleor/core/templates/bootstrap/_non_field_errors.html b/saleor/core/templates/bootstrap/_non_field_errors.html
deleted file mode 100644
index e8d3ef3698..0000000000
--- a/saleor/core/templates/bootstrap/_non_field_errors.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="alert alert-block alert-danger">
- {% for error in errors %}
- <p>{{ error }}</p>
- {% endfor %}
-</div>
diff --git a/saleor/core/templates/bootstrap/_pagination.html b/saleor/core/templates/bootstrap/_pagination.html
deleted file mode 100644
index 6c4ed62a7e..0000000000
--- a/saleor/core/templates/bootstrap/_pagination.html
+++ /dev/null
@@ -1,16 +0,0 @@
-{% load i18n %}
-{% if items.paginator.num_pages > 1 %}
- <nav>
- <ul class="pagination">
- <li {% if not items.has_previous %}class="disabled"{% endif %}><a href="{% if items.has_previous%}?page={{ items.previous_page_number }}{% else %}#{% endif %}" aria-label="{% trans "Previous" %}"><span aria-hidden="true">&laquo;</span></a></li>
- {% for page in items.paginator.page_range %}
- {% if page == items.number %}
- <li class="active"><a href="#">{{ page }} <span class="sr-only">(current)</span></a></li>
- {% else %}
- <li><a href="?page={{ page }}">{{ page }}</a></li>
- {% endif %}
- {% endfor %}
- <li {% if not items.has_next %}class="disabled"{% endif %}><a href="{% if items.has_next%}?page={{ items.next_page_number }}{% else %}#{% endif %}" aria-label="{% trans "Next" %}"><span aria-hidden="true">&raquo;</span></a></li>
- </ul>
- </nav>
-{% endif %}
\ No newline at end of file
diff --git a/saleor/core/templatetags/bootstrap.py b/saleor/core/templatetags/bootstrap.py
deleted file mode 100644
index 67ab240677..0000000000
--- a/saleor/core/templatetags/bootstrap.py
+++ /dev/null
@@ -1,81 +0,0 @@
-from django import forms
-from django.forms.forms import BoundField, BaseForm
-from django.forms.utils import ErrorList
-from django.template import Library, TemplateSyntaxError
-from django.template.loader import render_to_string
-from django.utils.safestring import mark_safe
-
-register = Library()
-
-TEMPLATE_ERRORS = 'bootstrap/_non_field_errors.html'
-TEMPLATE_HORIZONTAL = 'bootstrap/_field_horizontal.html'
-TEMPLATE_VERTICAL = 'bootstrap/_field_vertical.html'
-TEMPLATE_PAGINATION = 'bootstrap/_pagination.html'
-
-
-def render_non_field_errors(errors):
- if not errors:
- return ''
- context = {'errors': errors}
- return render_to_string(TEMPLATE_ERRORS, context=context)
-
-
-def render_field(bound_field, show_label, template):
- widget = bound_field.field.widget
-
- if isinstance(widget, forms.RadioSelect):
- input_type = 'radio'
- elif isinstance(widget, forms.Select):
- input_type = 'select'
- elif isinstance(widget, forms.Textarea):
- input_type = 'textarea'
- elif isinstance(widget, forms.CheckboxInput):
- input_type = 'checkbox'
- elif issubclass(type(widget), forms.MultiWidget):
- input_type = 'multi_widget'
- else:
- input_type = 'input'
-
- context = {
- 'bound_field': bound_field,
- 'input_type': input_type,
- 'show_label': show_label}
- return render_to_string(template, context=context)
-
-
-def as_bootstrap(obj, show_label, template):
- if isinstance(obj, BoundField):
- return render_field(obj, show_label, template)
- elif isinstance(obj, ErrorList):
- return render_non_field_errors(obj)
- elif isinstance(obj, BaseForm):
- non_field_errors = render_non_field_errors(obj.non_field_errors())
- fields = (render_field(field, show_label, template) for field in obj)
- form = ''.join(fields)
- return mark_safe(non_field_errors + form)
- else:
- raise TemplateSyntaxError('Filter accepts form, field and non fields '
- 'errors.')
-
-
-def as_horizontal_form(obj, show_label=True):
- return as_bootstrap(obj=obj, show_label=show_label,
- template=TEMPLATE_HORIZONTAL)
-
-
-def as_vertical_form(obj, show_label=True):
- return as_bootstrap(obj=obj, show_label=show_label,
- template=TEMPLATE_VERTICAL)
-
-
-def render_widget(obj, **attrs):
- return obj.as_widget(attrs=attrs)
-
-
-def as_pagination(items):
- context = {'items': items}
- return render_to_string(TEMPLATE_PAGINATION, context=context)
diff --git a/saleor/order/templates/order/details.html b/saleor/order/templates/order/details.html
index e03d194d49..47f3cde5ee 100644
--- a/saleor/order/templates/order/details.html
+++ b/saleor/order/templates/order/details.html
@@ -1,6 +1,5 @@
{% extends "base.html" %}
-{% load as_vertical_form from bootstrap %}
{% load gross from prices_i18n %}
{% load i18n %}
{% load staticfiles %}
diff --git a/saleor/order/templates/order/payment.html b/saleor/order/templates/order/payment.html
index 80db1bd60e..9ebae642f4 100644
--- a/saleor/order/templates/order/payment.html
+++ b/saleor/order/templates/order/payment.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load gross from prices_i18n %}
{% load i18n %}
{% load staticfiles %}
@@ -33,7 +33,7 @@
<p>{% trans "We are currently waiting for an external service to authorize your payment for this order." %}</p>
<p>{% trans "Current status" %}: <span class="label label-default">{{ waiting_payment.get_status_display }}</span></p>
<p>{% trans "Unless you are absolutely sure that the process will not complete (for example you have closed the browser window before paying), you should wait before attempting a new payment. Please be warned that if you try again and the previous transaction succeeds you might end up being charged twice." %}</p>
- {{ waiting_payment_form|as_vertical_form }}
+ {% bootstrap_form waiting_payment_form %}
<button type="submit" class="btn btn-danger">{% trans "I understand, allow me to pay again" %}</button>
</form>
</div>
diff --git a/saleor/order/templates/order/payment/default.html b/saleor/order/templates/order/payment/default.html
index 4dd1d129bc..e1a26745db 100644
--- a/saleor/order/templates/order/payment/default.html
+++ b/saleor/order/templates/order/payment/default.html
@@ -1,5 +1,5 @@
{% extends "order/payment/details.html" %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load i18n %}
{% block forms %}
@@ -10,7 +10,7 @@
<form id="payment-form" method="{{ form.method }}"{% if form.action %} action="{{ form.action }}"{% endif %}>
{% csrf_token %}
{{ form.media }}
- {{ form|as_vertical_form }}
+ {% bootstrap_form form %}
<div class="form-group">
<button type="submit" class="btn btn-primary">
{% trans "Save changes" %}
diff --git a/saleor/order/templates/order/payment/details.html b/saleor/order/templates/order/payment/details.html
index d11ab94d41..a4b3915223 100644
--- a/saleor/order/templates/order/payment/details.html
+++ b/saleor/order/templates/order/payment/details.html
@@ -1,5 +1,4 @@
{% extends "base.html" %}
-{% load as_horizontal_form from bootstrap %}
{% load i18n %}
{% block title %}{% trans "Payment" %} — {{ block.super }}{% endblock %}
diff --git a/saleor/order/templates/order/payment/paypal-card.html b/saleor/order/templates/order/payment/paypal-card.html
index d663b76f10..09dd0e4bf0 100644
--- a/saleor/order/templates/order/payment/paypal-card.html
+++ b/saleor/order/templates/order/payment/paypal-card.html
@@ -1,13 +1,13 @@
{% extends "order/payment/details.html" %}
-{% load as_horizontal_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load gross from prices_i18n %}
{% load i18n %}
{% block forms %}
<form method="post" class="form-horizontal">
{% csrf_token %}
- {{ form|as_horizontal_form }}
+ {% bootstrap_form form layout='horizontal' %}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">
diff --git a/saleor/order/templates/order/payment/stripe.html b/saleor/order/templates/order/payment/stripe.html
index 122723acba..da8001457d 100644
--- a/saleor/order/templates/order/payment/stripe.html
+++ b/saleor/order/templates/order/payment/stripe.html
@@ -1,12 +1,12 @@
{% extends "order/payment/details.html" %}
-{% load as_horizontal_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load i18n %}
{% block forms %}
<form method="{{ form.method }}" class="form-horizontal"{% if form.action %} action="{{ form.action }}"{% endif %}>
{% csrf_token %}
{{ form.media }}
- {{ form|as_horizontal_form }}
+ {% bootstrap_form form layout='horizontal' %}
{% if form.errors %}
<a class="btn" href="{% url "order:details" token=payment.order.token %}">{% trans "Change payment method" %}</a>
{% endif %}
diff --git a/saleor/product/templates/category/index.html b/saleor/product/templates/category/index.html
index e9ba52a68c..b77c7b85b5 100644
--- a/saleor/product/templates/category/index.html
+++ b/saleor/product/templates/category/index.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% load slice from shop %}
{% load static from staticfiles %}
-{% load as_pagination from bootstrap %}
+{% load bootstrap_pagination from bootstrap3 %}
{% block title %}{{ category }} — {{ block.super }}{% endblock %}
@@ -40,7 +40,7 @@
<div class="row">
{% include "category/_items.html" %}
</div>
- {{ products|as_pagination }}
+ {% bootstrap_pagination products %}
</div>
</div>
{% endblock content %}
diff --git a/saleor/product/templates/product/details.html b/saleor/product/templates/product/details.html
index 8d36be1ce4..fc91128621 100644
--- a/saleor/product/templates/product/details.html
+++ b/saleor/product/templates/product/details.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load discounted_price_range price_difference from discount %}
{% load i18n %}
{% load gross from prices_i18n %}
@@ -62,7 +62,7 @@
{% block orderform %}
<form role="form" class="product-form form-vertical" method="post" action=".">
{% csrf_token %}
- {{ form|as_vertical_form }}
+ {% bootstrap_form form %}
<div class="form-group">
<button class="btn btn-lg btn-block btn-primary">
diff --git a/saleor/registration/templates/registration/change_password.html b/saleor/registration/templates/registration/change_password.html
index 5266cac2f9..b7f15d68eb 100644
--- a/saleor/registration/templates/registration/change_password.html
+++ b/saleor/registration/templates/registration/change_password.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% load i18n %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% block title %}{% trans "Change password" %}{% endblock %}
@@ -19,7 +19,7 @@
{% csrf_token %}
<fieldset>
<legend>{% trans 'Change password' %}</legend>
- {{ form|as_vertical_form }}
+ {% bootstrap_form form %}
<input type="hidden" name="next" value="{{ next }}" />
</fieldset>
diff --git a/saleor/registration/templates/registration/login.html b/saleor/registration/templates/registration/login.html
index 4e1362ba12..1b3ca985c2 100644
--- a/saleor/registration/templates/registration/login.html
+++ b/saleor/registration/templates/registration/login.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load i18n %}
{% block title %}{% trans "Login" %} — {{ block.super }}{% endblock %}
@@ -13,7 +13,7 @@
{% csrf_token %}
<fieldset>
<legend>{% trans 'Log in' %}</legend>
- {{ form|as_vertical_form }}
+ {% bootstrap_form form %}
<input type="hidden" name="next" value="{{ next }}" />
</fieldset>
diff --git a/saleor/registration/templates/registration/request_email_confirmation.html b/saleor/registration/templates/registration/request_email_confirmation.html
index 1b5152a8fe..9697a6c5f7 100644
--- a/saleor/registration/templates/registration/request_email_confirmation.html
+++ b/saleor/registration/templates/registration/request_email_confirmation.html
@@ -1,5 +1,5 @@
{% extends "base.html" %}
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% load i18n %}
{% block title %}{% trans "Register or reset your password" %} — {{ block.super }}{% endblock %}
@@ -18,7 +18,7 @@
{% csrf_token %}
<fieldset>
<legend>{% trans 'Register or reset your password' %}</legend>
- {{ form|as_vertical_form }}
+ {% bootstrap_form form %}
<input type="hidden" name="next" value="{{ next }}" />
</fieldset>
<div class="form-group text-right">
diff --git a/saleor/registration/templates/registration/set_password.html b/saleor/registration/templates/registration/set_password.html
index f3b6f8a77f..4ed577a5a8 100644
--- a/saleor/registration/templates/registration/set_password.html
+++ b/saleor/registration/templates/registration/set_password.html
@@ -1,6 +1,6 @@
{% extends "base.html" %}
{% load i18n %}
-{% load as_horizontal_form from bootstrap %}
+{% load bootstrap_form from bootstrap3 %}
{% block title %}{% trans "Set password" %} — {{ block.super }}{% endblock %}
@@ -9,7 +9,7 @@
{% csrf_token %}
<fieldset>
<legend>{% trans 'Set password' %}</legend>
- {{ form|as_horizontal_form }}
+ {% bootstrap_form form layout='horizontal' %}
</fieldset>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
diff --git a/saleor/settings.py b/saleor/settings.py
index 3d33c5aceb..643de71834 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -140,6 +140,7 @@ INSTALLED_APPS = [
# External apps
'versatileimagefield',
'babeldjango',
+ 'bootstrap3',
'django_prices',
'emailit',
'mptt',
diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scss
index 92ecad53c2..4f1b58f06c 100644
--- a/saleor/static/scss/_app.scss
+++ b/saleor/static/scss/_app.scss
@@ -48,10 +48,6 @@ $icon-font-path: "../fonts/";
}
}
-.form-group.required .control-label:after{
- content: '*';
-}
-
.breadcrumb {
> li+li {
&:before {
@@ -134,43 +130,6 @@ $icon-font-path: "../fonts/";
}
}
-#id_method {
- @include make-row;
- list-style: none;
- padding: 0;
-
- li {
- @include make-xs-column(6);
- @include make-sm-column(4);
- margin-bottom: $grid-gutter-width/3;
- white-space: nowrap;
- }
-
- li:not(:first-child) {
- label {
- font-size: 0;
-
- @each $provider in (default, authorizenet, braintree, coinbase, cybersource, dotpay,
- wallet, paypal, sage, sofort, stripe) {
- input[value=#{$provider}] {
- margin: 6px 110px 6px 0;
-
- &:after {
- background: url("../img/#{$provider}-logo.png") no-repeat left;
- background-size: contain;
- content: "";
- display: block;
- float: left;
- height: 26px;
- margin: -6px 0 0 18px;
- width: 100px;
- }
- }
- }
- }
- }
-}
-
.nav {
> li {
> a {
diff --git a/saleor/userprofile/templates/userprofile/snippets/address-form.html b/saleor/userprofile/templates/userprofile/snippets/address-form.html
index 3b3baf790a..c71d6e1082 100644
--- a/saleor/userprofile/templates/userprofile/snippets/address-form.html
+++ b/saleor/userprofile/templates/userprofile/snippets/address-form.html
@@ -1,37 +1,37 @@
-{% load as_vertical_form from bootstrap %}
+{% load bootstrap_field from bootstrap3 %}
<div class="row">
<div class="col-sm-6">
- {{ address_form.first_name|as_vertical_form }}
+ {% bootstrap_field address_form.first_name %}
</div>
<div class="col-sm-6">
- {{ address_form.last_name|as_vertical_form }}
+ {% bootstrap_field address_form.last_name %}
</div>
</div>
-{{ address_form.company_name|as_vertical_form }}
+{% bootstrap_field address_form.company_name %}
<div class="row">
<div class="col-sm-8">
- {{ address_form.street_address_1|as_vertical_form }}
+ {% bootstrap_field address_form.street_address_1 %}
</div>
<div class="col-sm-4">
- {{ address_form.street_address_2|as_vertical_form }}
+ {% bootstrap_field address_form.street_address_2 %}
</div>
</div>
<div class="row">
<div class="col-sm-6">
- {{ address_form.city|as_vertical_form }}
+ {% bootstrap_field address_form.city %}
</div>
<div class="col-sm-6">
- {{ address_form.city_area|as_vertical_form }}
+ {% bootstrap_field address_form.city_area %}
</div>
</div>
<div class="row">
<div class="col-sm-8">
- {{ address_form.country_area|as_vertical_form }}
+ {% bootstrap_field address_form.country_area %}
</div>
<div class="col-sm-4">
- {{ address_form.postal_code|as_vertical_form }}
+ {% bootstrap_field address_form.postal_code %}
</div>
</div>
-{{ address_form.country|as_vertical_form }}
-{{ address_form.phone|as_vertical_form }}
+{% bootstrap_field address_form.country %}
+{% bootstrap_field address_form.phone %}