from django import forms from core.styles import label_span, STYLE class WeeklyReport(forms.Form): department = forms.CharField( label=label_span("Abteilung"), max_length=150, widget=forms.TextInput( attrs={ "placeholder": "Abteilung", "class": STYLE["text-input"], } ), ) company_text = forms.CharField( label=label_span("Betriebliche Tätigkeiten"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Betriebliche Tätigkeiten", } ), ) week_topic = forms.CharField( label=label_span("Thema der Woche"), max_length=600, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 10, "placeholder": "Thema der Woche", } ), ) school_text = forms.CharField( label=label_span("Berufsschule"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Berufsschule", } ), ) img = forms.ImageField( label=label_span("Bild"), required=False, widget=forms.ClearableFileInput( attrs={ "class": "block w-full p-2 text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400", "accept": "image/*", } ), ) @property def display_names(self): return { "department": self.fields["department"].label, "company_text": self.fields["company_text"].label, "week_topic": self.fields["week_topic"].label, "school_text": self.fields["school_text"].label, } def content_values(self) -> dict: if self.is_valid(): return { "company_text": self.cleaned_data["company_text"], "week_topic": self.cleaned_data["week_topic"], "school_text": self.cleaned_data["school_text"], } class DailyReport(forms.Form): department = forms.CharField( label=label_span("Abteilung"), max_length=150, widget=forms.TextInput( attrs={ "placeholder": "Abteilung", "class": STYLE["text-input"], } ), ) week_topic = forms.CharField( label=label_span("Thema der Woche"), max_length=600, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Thema der Woche", } ), ) monday_text = forms.CharField( label=label_span("Montag"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Montag", } ), ) tuesday_text = forms.CharField( label=label_span("Dienstag"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Dienstag", } ), ) wednesday_text = forms.CharField( label=label_span("Mittwoch"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Mittwoch,", } ), ) thursday_text = forms.CharField( label=label_span("Donnerstag"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Donnerstag", } ), ) friday_text = forms.CharField( label=label_span("Freitag"), max_length=300, widget=forms.Textarea( attrs={ "class": STYLE["text-input"], "rows": 5, "placeholder": "Freitag", } ), ) img = forms.ImageField( label=label_span("Bild"), required=False, widget=forms.ClearableFileInput( attrs={ "class": "block w-full p-2 text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400", "accept": "image/*", } ), ) @property def display_names(self) -> dict: return { "department": self.fields["department"].label, "week_topic": self.fields["week_topic"].label, "monday_text": self.fields["monday_text"].label, "tuesday_text": self.fields["tuesday_text"].label, "wednesday_text": self.fields["wednesday_text"].label, "thursday_text": self.fields["thursday_text"].label, "friday_text": self.fields["friday_text"].label, } def content_values(self) -> dict: if self.is_valid(): return { "week_topic": self.cleaned_data["week_topic"], "monday_text": self.cleaned_data["monday_text"], "tuesday_text": self.cleaned_data["tuesday_text"], "wednesday_text": self.cleaned_data["wednesday_text"], "thursday_text": self.cleaned_data["thursday_text"], "friday_text": self.cleaned_data["friday_text"], } def choose_report_kind(kind, request=None, files=None): match kind: case "weekly": return WeeklyReport(request, files) case "daily": return DailyReport(request, files)