diff --git a/cof/fixtures/gestion.json b/cof/fixtures/gestion.json index 6d1bd76f..c8020cb6 100644 --- a/cof/fixtures/gestion.json +++ b/cof/fixtures/gestion.json @@ -67,63 +67,6 @@ "model": "cof.surveyquestionanswer", "pk": 5 }, -{ - "fields": { - "old": false, - "description": "On va casser du romain.", - "end_date": "2016-09-12T00:00:00Z", - "title": "Bataille de Gergovie", - "image": "", - "location": "Gergovie", - "registration_open": true, - "start_date": "2016-09-09T00:00:00Z" - }, - "model": "cof.event", - "pk": 1 -}, -{ - "fields": { - "default": "", - "event": 1, - "fieldtype": "text", - "name": "Commentaires" - }, - "model": "cof.eventcommentfield", - "pk": 1 -}, -{ - "fields": { - "multi_choices": true, - "event": 1, - "name": "Potion magique" - }, - "model": "cof.eventoption", - "pk": 1 -}, -{ - "fields": { - "event_option": 1, - "value": "Je suis alergique" - }, - "model": "cof.eventoptionchoice", - "pk": 1 -}, -{ - "fields": { - "event_option": 1, - "value": "J'en veux" - }, - "model": "cof.eventoptionchoice", - "pk": 2 -}, -{ - "fields": { - "event_option": 1, - "value": "Je suis tomb\u00e9 dans la marmite quand j'\u00e9tais petit" - }, - "model": "cof.eventoptionchoice", - "pk": 3 -}, { "fields": { "name": "Bagarre" diff --git a/cof/forms.py b/cof/forms.py index 7f3a0614..072d3e70 100644 --- a/cof/forms.py +++ b/cof/forms.py @@ -12,58 +12,15 @@ from django.forms.formsets import BaseFormSet, formset_factory from django.db.models import Max from django.core.validators import MinLengthValidator -from .models import CofProfile, EventCommentValue, CalendarSubscription +from .models import CofProfile, CalendarSubscription from .widgets import TriStateCheckbox -from gestion.models import Profile +from gestion.models import Profile, EventCommentValue from gestion.shared import lock_table, unlock_table from bda.models import Spectacle -class EventForm(forms.Form): - def __init__(self, *args, **kwargs): - event = kwargs.pop("event") - self.event = event - current_choices = kwargs.pop("current_choices", None) - super(EventForm, self).__init__(*args, **kwargs) - choices = {} - if current_choices: - for choice in current_choices.all(): - if choice.event_option.id not in choices: - choices[choice.event_option.id] = [choice.id] - else: - choices[choice.event_option.id].append(choice.id) - all_choices = choices - for option in event.options.all(): - choices = [(choice.id, choice.value) - for choice in option.choices.all()] - if option.multi_choices: - initial = [] if option.id not in all_choices \ - else all_choices[option.id] - field = forms.MultipleChoiceField( - label=option.name, - choices=choices, - widget=CheckboxSelectMultiple, - required=False, - initial=initial) - else: - initial = None if option.id not in all_choices \ - else all_choices[option.id][0] - field = forms.ChoiceField(label=option.name, - choices=choices, - widget=RadioSelect, - required=False, - initial=initial) - field.option_id = option.id - self.fields["option_%d" % option.id] = field - - def choices(self): - for name, value in self.cleaned_data.items(): - if name.startswith('option_'): - yield (self.fields[name].option_id, value) - - class SurveyForm(forms.Form): def __init__(self, *args, **kwargs): survey = kwargs.pop("survey") diff --git a/cof/templates/home.html b/cof/templates/home.html index 7574e06e..bbb9632b 100644 --- a/cof/templates/home.html +++ b/cof/templates/home.html @@ -8,16 +8,6 @@