Add checkbox to accept terms on registration.
--- a/src/iconolab/auth/forms.py Tue May 16 11:29:33 2017 +0200
+++ b/src/iconolab/auth/forms.py Tue May 16 12:36:38 2017 +0200
@@ -11,10 +11,11 @@
class UserCreationForm(UserCreationForm):
email = forms.EmailField(required=True)
+ accept_terms = forms.BooleanField(required=True, label="Accepter la charte d'utilisation")
class Meta:
model = User
- fields = ("username", "email", "password1", "password2")
+ fields = ("username", "email", "password1", "password2", "accept_terms")
def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)
--- a/src/iconolab/templates/registration/register.html Tue May 16 11:29:33 2017 +0200
+++ b/src/iconolab/templates/registration/register.html Tue May 16 12:36:38 2017 +0200
@@ -10,10 +10,20 @@
{% csrf_token %}
{% for field in form %}
<fieldset class="form-group {% if field.errors %}has-error{% endif %}">
+
+ {% if field.name == 'accept_terms' %}
+ <div class="checkbox">
+ <label>
+ <input type="checkbox" name="{{ field.name }}"> {{ field.label }}
+ </label>
+ </div>
+ {% else %}
<label class="control-label" for="id_{{ field.name }}">{{ field.label }}</label>
<input type="{{ field.field.widget.input_type }}" class="form-control"
name="{{ field.name }}"
id="id_{{ field.name }}" >
+ {% endif %}
+
{% if field.errors %}
<span class="help-block">{{ field.errors.as_text }}</span>
{% else %}