Skip to content

Commit

Permalink
(forum) make image field optionnal in ForumForm
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed May 28, 2024
1 parent fd9186c commit bef9702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lacommunaute/forum/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ForumForm(forms.ModelForm):
description = forms.CharField(
widget=forms.Textarea(attrs={"rows": 20}), required=False, label="Contenu (markdown autorisé)"
)
image = forms.ImageField(label="Banniere de couverture")
image = forms.ImageField(required=False, label="Banniere de couverture")

def save(self, commit=True):
forum = super().save(commit=False)
Expand Down
4 changes: 4 additions & 0 deletions lacommunaute/forum/tests/tests_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ def test_form_field():
form = ForumForm()
assert form.Meta.model == Forum
assert form.Meta.fields == ["name", "short_description", "description", "image"]
assert form.fields["name"].required
assert form.fields["short_description"].required
assert not form.fields["description"].required
assert not form.fields["image"].required

0 comments on commit bef9702

Please sign in to comment.