Merge branch 'Aufinal/select_all' into 'master'

Aufinal/fixes_85

Rajoute des boutons pour tout (dé-)sélectionner dans la vue d'inscription au calendrier.

Utilise `bootstrap` pour afficher le formulaire.

See merge request !166
This commit is contained in:
Martin Pepin 2017-02-09 12:29:08 +01:00
commit e32faf6182
3 changed files with 22 additions and 8 deletions

View file

@ -378,12 +378,12 @@ EventFormset = formset_factory(AdminEventForm, BaseEventRegistrationFormset)
class CalendarForm(forms.ModelForm): class CalendarForm(forms.ModelForm):
subscribe_to_events = forms.BooleanField( subscribe_to_events = forms.BooleanField(
initial=True, initial=True,
label="Événements du COF.") label="Événements du COF")
subscribe_to_my_shows = forms.BooleanField( subscribe_to_my_shows = forms.BooleanField(
initial=True, initial=True,
label="Les spectacles pour lesquels j'ai obtenu une place.") label="Les spectacles pour lesquels j'ai obtenu une place")
other_shows = forms.ModelMultipleChoiceField( other_shows = forms.ModelMultipleChoiceField(
label="Spectacles supplémentaires.", label="Spectacles supplémentaires",
queryset=Spectacle.objects.filter(tirage__active=True), queryset=Spectacle.objects.filter(tirage__active=True),
widget=forms.CheckboxSelectMultiple, widget=forms.CheckboxSelectMultiple,
required=False) required=False)

View file

@ -1,4 +1,5 @@
{% extends "base_title.html" %} {% extends "base_title.html" %}
{% load bootstrap %}
{% block realcontent %} {% block realcontent %}
@ -36,8 +37,21 @@ souscrire aux événements du COF et/ou aux spectacles BdA.
<form action="" method="post"> <form action="" method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {{ form | bootstrap }}
<input type="submit" value="Enregistrer" class="btn btn-primary" /> <p>
<button type="button" class="btn btn-default" onClick="select(true)">Tout sélectionner</button>
<button type="button" class="btn btn-default" onClick="select(false)">Tout désélectionner</button>
</p>
<input type="submit" value="Enregistrer" class="btn btn-primary center-block" />
</form> </form>
<script language="JavaScript">
function select(check) {
checkboxes = document.getElementsByName("other_shows");
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = check;
}
}
</script>
{% endblock %} {% endblock %}

View file

@ -686,15 +686,15 @@ def calendar(request):
subscription.token = uuid.uuid4() subscription.token = uuid.uuid4()
subscription.save() subscription.save()
form.save_m2m() form.save_m2m()
return render(request, "calendar_subscription.html", return render(request, "gestioncof/calendar_subscription.html",
{'form': form, {'form': form,
'success': True, 'success': True,
'token': str(subscription.token)}) 'token': str(subscription.token)})
else: else:
return render(request, "calendar_subscription.html", return render(request, "gestioncof/calendar_subscription.html",
{'form': form, 'error': "Formulaire incorrect"}) {'form': form, 'error': "Formulaire incorrect"})
else: else:
return render(request, "calendar_subscription.html", return render(request, "gestioncof/calendar_subscription.html",
{'form': CalendarForm(instance=instance), {'form': CalendarForm(instance=instance),
'token': instance.token if instance else None}) 'token': instance.token if instance else None})