from django import forms

from ..models import Veranstaltung, Veranstaltungsteilnehmer


class VeranstaltungForm(forms.ModelForm):
    """Form für das Erstellen und Bearbeiten von Veranstaltungen inkl. Serienbrief-Felder"""

    class Meta:
        model = Veranstaltung
        fields = [
            "titel", "datum", "uhrzeit", "ort", "adresse",
            "beschreibung", "status", "budget_pro_person",
            "betreff", "briefvorlage",
            "unterschrift_1_name", "unterschrift_1_titel",
            "unterschrift_2_name", "unterschrift_2_titel",
        ]
        widgets = {
            "titel": forms.TextInput(attrs={"class": "form-control"}),
            "datum": forms.DateInput(attrs={"class": "form-control", "type": "date"}),
            "uhrzeit": forms.TimeInput(attrs={"class": "form-control", "type": "time"}),
            "ort": forms.TextInput(attrs={"class": "form-control"}),
            "adresse": forms.Textarea(attrs={"class": "form-control", "rows": 2}),
            "beschreibung": forms.Textarea(attrs={"class": "form-control", "rows": 3}),
            "status": forms.Select(attrs={"class": "form-select"}),
            "budget_pro_person": forms.NumberInput(attrs={"class": "form-control", "step": "0.01"}),
            "betreff": forms.TextInput(attrs={"class": "form-control"}),
            "briefvorlage": forms.Textarea(attrs={"class": "form-control", "rows": 12}),
            "unterschrift_1_name": forms.TextInput(attrs={"class": "form-control"}),
            "unterschrift_1_titel": forms.TextInput(attrs={"class": "form-control"}),
            "unterschrift_2_name": forms.TextInput(attrs={"class": "form-control"}),
            "unterschrift_2_titel": forms.TextInput(attrs={"class": "form-control"}),
        }


class VeranstaltungsteilnehmerForm(forms.ModelForm):
    """Form für das Erstellen und Bearbeiten von Veranstaltungsteilnehmern"""

    class Meta:
        model = Veranstaltungsteilnehmer
        fields = [
            "anrede", "vorname", "nachname",
            "strasse", "plz", "ort", "email",
            "rsvp_status", "bemerkungen",
            "paechter", "destinataer",
        ]
        widgets = {
            "anrede": forms.Select(attrs={"class": "form-select"}),
            "vorname": forms.TextInput(attrs={"class": "form-control"}),
            "nachname": forms.TextInput(attrs={"class": "form-control"}),
            "strasse": forms.TextInput(attrs={"class": "form-control"}),
            "plz": forms.TextInput(attrs={"class": "form-control"}),
            "ort": forms.TextInput(attrs={"class": "form-control"}),
            "email": forms.EmailInput(attrs={"class": "form-control"}),
            "rsvp_status": forms.Select(attrs={"class": "form-select"}),
            "bemerkungen": forms.Textarea(attrs={"class": "form-control", "rows": 2}),
            "paechter": forms.Select(attrs={"class": "form-select"}),
            "destinataer": forms.Select(attrs={"class": "form-select"}),
        }
