Add charte popup and functionality

This commit is contained in:
Ludovic Stephan 2019-09-18 19:36:02 +02:00
parent 0a1b20dd4e
commit 5db7eef1d7
2 changed files with 40 additions and 1 deletions

View file

@ -4,6 +4,8 @@
{% block extra_head %}
<script src="{% static 'js/jquery-ui.min.js' %}" type="text/javascript"></script>
<script src="{% static "js/jquery.ui.touch-punch.min.js" %}" type="text/javascript"></script>
<script src="{% static "kfet/js/jquery-confirm.js" %}" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/jquery-confirm.css' %}">
<link type="text/css" rel="stylesheet" href="{% static "css/jquery-ui.min.css" %}" />
<link type="text/css" rel="stylesheet" href="{% static "css/bda.css" %}" />
{% endblock %}
@ -118,11 +120,45 @@ var django = {
});
</script>
<input type="hidden" name="dbstate" value="{{ dbstate }}" />
<input type="submit" class="btn btn-primary" value="Enregistrer" />
<input type="submit" class="btn btn-primary" id="bda-inscr" value="Enregistrer" />
</div>
<p class="footnotes">
<sup>1</sup>: cette liste de v&oelig;ux est ordonnée (du plus important au moins important), pour ajuster la priorité vous pouvez déplacer chaque v&oelig;u.<br />
</p>
</div>
</form>
{% if not charte %}
<script>
(function ($) {
function link_charte() {
$.confirm({
title: 'Charte du BdA',
columnClass: 'col-md-6 col-md-offset-3',
content: `
<div>
En vous inscrivant à ce tirage du Bureau des Arts, vous vous engagez à \
respecter la charte du BdA:</br> \
<a target="_blank" href='https://bda.ens.fr/lequipe/charte-bda/'>https://bda.ens.fr/lequipe/charte-bda/</a>
</div>`,
backgroundDismiss: true,
animation:'top',
closeAnimation:'bottom',
keyboardEnabled: true,
confirmButton: '<span class="glyphicon glyphicon-ok"></span>',
cancelButton: '<span class="glyphicon glyphicon-remove"></span>',
confirm: function() {
$("#bda_form").submit();
},
});
}
$(document).ready(function($) {
$("#bda-inscr").click(function(e) {
e.preventDefault();
link_charte();
})
})
})(django.jQuery);
</script>
{% endif %}
{% endblock %}

View file

@ -211,6 +211,8 @@ def inscription(request, tirage_id):
if formset.is_valid():
formset.save()
formset = BdaFormSet(instance=participant)
participant.accepte_charte = True
participant.save()
messages.success(
request, "Votre inscription a été mise à jour avec succès !"
)
@ -238,6 +240,7 @@ def inscription(request, tirage_id):
"total_price": total_price,
"dbstate": dbstate,
"tirage": tirage,
"charte": participant.accepte_charte,
},
)