forked from beba/foerderbarometer
cleaned up project forms
This commit is contained in:
parent
d1cda4c1a9
commit
c27e4c5183
|
|
@ -307,13 +307,12 @@ class ListForm(BaseApplicationForm, CommonOrderMixin):
|
|||
self.fields['address'].initial = ''
|
||||
|
||||
|
||||
class ProjectRequestForm(CommonOrderMixin, forms.ModelForm):
|
||||
class ProjectRequestForm(BaseApplicationForm, CommonOrderMixin):
|
||||
"""
|
||||
Public-facing form for < 1000 EUR project requests.
|
||||
|
||||
Key points:
|
||||
- JSONField-backed multi-selects are exposed as MultipleChoiceField with checkbox widgets.
|
||||
- We return `list(...)` in clean_* so the JSONField gets a native list.
|
||||
- Extra UX tweaks: textareas for long text, number inputs with min/max/step, help_texts with links via format_html.
|
||||
"""
|
||||
|
||||
|
|
@ -374,13 +373,6 @@ class ProjectRequestForm(CommonOrderMixin, forms.ModelForm):
|
|||
'Falls du noch weitere Informationen hast, teile sie gern an dieser Stelle mit uns. Für umfangreichere Informationen, schreibe uns eine E-Mail an <a href="mailto:community@wikimedia.de">community@wikimedia.de</a>.'),
|
||||
}
|
||||
|
||||
# Persist multi-selects as Python lists so JSONField stores a JSON array
|
||||
def clean_categories(self):
|
||||
return list(self.cleaned_data.get('categories', []))
|
||||
|
||||
def clean_wikimedia_projects(self):
|
||||
return list(self.cleaned_data.get('wikimedia_projects', []))
|
||||
|
||||
|
||||
class ProjectRequestAdminForm(forms.ModelForm):
|
||||
"""
|
||||
|
|
@ -395,7 +387,7 @@ class ProjectRequestAdminForm(forms.ModelForm):
|
|||
categories = forms.MultipleChoiceField(
|
||||
choices=[(c, c) for c in PROJECT_CATEGORIES],
|
||||
widget=forms.CheckboxSelectMultiple,
|
||||
label='Projektkategorie'
|
||||
label='Projektkategorie(n)'
|
||||
)
|
||||
wikimedia_projects = forms.MultipleChoiceField(
|
||||
choices=[(w, w) for w in WIKIMEDIA_CHOICES],
|
||||
|
|
@ -404,9 +396,6 @@ class ProjectRequestAdminForm(forms.ModelForm):
|
|||
)
|
||||
|
||||
class Meta:
|
||||
model = ProjectRequest
|
||||
fields = "__all__"
|
||||
|
||||
# Make longer texts easier to edit in the admin UI
|
||||
widgets = {
|
||||
'description': forms.Textarea(attrs={'rows': 5}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue