from django import forms

from .models import Survey


class SurveyForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if 'survey_id' in self.initial:
            self.fields['survey_id'].disabled = True

    class Meta:
        model = Survey
        exclude = ('completed_registrations', 'completed_teams',)
        widgets = {
            'completed_registrations': forms.SelectMultiple(attrs={
                'class': 'selectpicker',
                'data-live-search': 'true',
                'data-live-search-normalize': 'true',
                'data-width': 'fit',
            }),
            'completed_teams': forms.SelectMultiple(attrs={
                'class': 'selectpicker',
                'data-live-search': 'true',
                'data-live-search-normalize': 'true',
                'data-width': 'fit',
            }),
        }
