8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +00:00

checkbox pour les cableurs

This commit is contained in:
grisel-davy 2018-08-25 21:36:54 +02:00
parent dc5ba19e59
commit 53a632fe59

View file

@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load widget_tweaks %} {% load widget_tweaks %}
{% load massive_bootstrap_form %} {% load massive_bootstrap_form %}
{% load static %} {% load static %}
{% load acl %}
{% load i18n %} {% load i18n %}
{% block title %}{% trans "Users" %}{% endblock %} {% block title %}{% trans "Users" %}{% endblock %}
@ -89,27 +90,40 @@ function submitBday() {
</div> </div>
<div class="form-group"> <div class="form-group">
<div id="file" style="display:none;"> {% if user.is_authenticated %}
{% can_edit user %}
<div class="disclaimer" style="display:none;">
<input type="checkbox" id="check_disclaimer" name="box_disclaimer" requiered=True />
<label for="scales">Décharge parentale reçue</label>
{% acl_end %}
{% else %}
<div class="disclaimer" style="display:none;">
{{ userform.disclaimer.label_tag }} {{ userform.disclaimer.label_tag }}
{% render_field userform.disclaimer class="form-control" %} {% render_field userform.disclaimer class="form-control" %}
</div> </div>
{% endif %}
</div> </div>
<script type='text/javascript'> <script type='text/javascript'>
function submitBday() { function submitBday() {
var field = document.getElementById("file"); var fields = document.getElementsByClassName("disclaimer");
var Bdate = document.getElementById('bday').value; var Bdate = document.getElementById('bday').value;
var Bday = +new Date(Bdate); var Bday = +new Date(Bdate);
var age = ((Date.now() - Bday) / (31557600000)); var age = ((Date.now() - Bday) / (31557600000));
var len = fields.length;
if (age < 18){ if (age < 18){
field.style.display = "block"; for (i=0; i<len; ++i) {
document.getElementById("{{userform.disclaimer.auto_id}}").required = true; fields[i].style.display = "block";
fields[i].required = true;
}
} }
else{ else{
field.style.display = "none"; for (i=0; i<len; ++i) {
document.getElementById("{{userform.disclaimer.auto_id}}").required = false; fields[i].style.display = "none";
fields[i].required = false;
}
} }
} }