instru liste for multiinstrumentiste answer in doodle

This commit is contained in:
Lucie Galland 2021-09-30 08:38:47 +02:00
parent 446acd1cb7
commit fc4577c661
7 changed files with 62 additions and 18 deletions

View file

@ -37,7 +37,7 @@ class EventForm(forms.ModelForm):
class ParticipantsForm(forms.ModelForm):
class Meta:
model = Participants
fields = ("reponse", "details", "dont_play_main", "instrument")
fields = ("reponse", "details", "dont_play_main", "instrument","instrument_autre")
widgets = {
"details": forms.Textarea(attrs={"placeholder": _("50 caractères max")}),
}

View file

@ -0,0 +1,23 @@
# Generated by Django 2.2.24 on 2021-09-29 14:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('calendrier', '0005_auto_20210726_0949'),
]
operations = [
migrations.AddField(
model_name='participants',
name='instrument_autre',
field=models.CharField(blank=True, max_length=50, null=True),
),
migrations.AlterField(
model_name='participants',
name='instrument',
field=models.CharField(blank=True, choices=[('Clarinette', 'Clarinette'), ('Euphonium', 'Euphonium'), ('Percussion', 'Percussion'), ('Piccolo', 'Piccolo'), ('Saxophone Alto', 'Saxophone Alto'), ('Saxophone Ténor', 'Saxophone Ténor'), ('Saxophone Baryton', 'Saxophone Baryton'), ('Souba', 'Souba'), ('Trombone', 'Trombone'), ('Trompette', 'Trompette'), ('Autre', 'Autre'), ('ne sais pas', 'Je ne sais pas encore')], max_length=50, null=True),
),
]

View file

@ -3,6 +3,7 @@ import uuid
from django.db import models
from django.utils.translation import gettext_lazy as _
from gestion.models import INSTRU_CHOICES
from gestion.models import ErnestoUser
ANSWERS = (
@ -61,7 +62,8 @@ class Participants(models.Model):
reponse = models.CharField(
_("Réponse"), max_length=20, default="non", choices=ANSWERS
)
instrument = models.CharField(max_length=50, blank=True, null=True)
instrument = models.CharField(max_length=50, blank=True, null=True, choices=INSTRU_CHOICES)
instrument_autre = models.CharField(max_length=50, blank=True, null=True)
dont_play_main = models.CharField(
_("Je veux jouer d'un instrument different de mon instrument principal:"),
default="Non",

View file

@ -35,6 +35,8 @@
<div id="dont_play_main_field" {% if request.user.profile.multi_instrumentiste == "Non" %} style="display: none; "{% endif %}>
{% elif field.id_for_label == "id_instrument" %}
<div id="instru_ev_field" style="display: none; ">
{% elif field.id_for_label == "id_instrument_autre" %}
<div id="instru_autre_ev_field" style="display: none; ">
{% else %}
<div>
@ -71,4 +73,15 @@
}
});
</script>
<script type="text/javascript">
$('#id_instrument').on('change', function() {
if (this.value == "Autre" ) {
$('#instru_autre_ev_field').show();
}
else {
$('#instru_autre_ev_field').hide();
}
});
</script>
{% endblock %}

View file

@ -180,7 +180,11 @@
</td>
<td>{% if participant.dont_play_main == 'Oui' %}
{% if participant.instrument == "Autre" %}
{{participant.instrument_autre}}
{% else %}
{{participant.instrument}}
{% endif %}
{% elif participant.participant.instru == "Autre" %}
{{participant.participant.instru_autre}}
{% else %}

View file

@ -195,7 +195,10 @@ class ViewEvent(LoginRequiredMixin, TemplateView):
if instru == "Autre":
instru = participant.participant.instru_autre
if participant.dont_play_main == "Oui":
instru = participant.instrument
if participant.instrument == "Autre":
instru = participant.instrument_autre
else:
instru = participant.instrument
sure, maybe, namesoui, namespe, namesnon = instrument_count[instru]

View file

@ -8,7 +8,20 @@ from django.utils.translation import gettext_lazy as _
import os
from django.conf import settings
INSTRU_CHOICES = [
("Clarinette", _("Clarinette")),
("Euphonium", _("Euphonium")),
("Percussion", _("Percussion")),
("Piccolo", _("Piccolo")),
("Saxophone Alto", _("Saxophone Alto")),
("Saxophone Ténor", _("Saxophone Ténor")),
("Saxophone Baryton", _("Saxophone Baryton")),
("Souba", _("Souba")),
("Trombone", _("Trombone")),
("Trompette", _("Trompette")),
("Autre", _("Autre")),
("ne sais pas", _("Je ne sais pas encore")),
]
class Photo(models.Model):
PHOTO_PLACEMENT = (
("home_join", _("Rejoignez nous")),
@ -75,20 +88,6 @@ class ErnestoUser(models.Model):
help_text=_("seulement visible par les chef·fe·s"),
)
INSTRU_CHOICES = [
("Clarinette", _("Clarinette")),
("Euphonium", _("Euphonium")),
("Percussion", _("Percussion")),
("Piccolo", _("Piccolo")),
("Saxophone Alto", _("Saxophone Alto")),
("Saxophone Ténor", _("Saxophone Ténor")),
("Saxophone Baryton", _("Saxophone Baryton")),
("Souba", _("Souba")),
("Trombone", _("Trombone")),
("Trompette", _("Trompette")),
("Autre", _("Autre")),
("ne sais pas", _("Je ne sais pas encore")),
]
COLORS_CHOICES = [
("#e4522f#ffffff", _("Orange et Blanc")),