mirror of
https://github.com/ae-utbm/sith.git
synced 2026-04-02 16:59:43 +00:00
apply correct default club_status when GET data is missing
This commit is contained in:
@@ -331,6 +331,11 @@ class ClubSearchForm(forms.ModelForm):
|
|||||||
initial=True,
|
initial=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, data: dict | None = None, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, data=data, **kwargs)
|
||||||
|
if data is not None and "club_status" not in data:
|
||||||
|
# if the key is missing, it is considered as None,
|
||||||
|
# even though we want the default True value to be applied in such a case
|
||||||
|
# so we enforce it.
|
||||||
|
self.fields["club_status"].value = True
|
||||||
self.fields["name"].required = False
|
self.fields["name"].required = False
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class ClubListView(AllowFragment, FormMixin, ListView):
|
|||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
res = super().get_form_kwargs()
|
res = super().get_form_kwargs()
|
||||||
if self.request.GET:
|
if self.request.method == "GET":
|
||||||
res |= {"data": self.request.GET, "initial": self.request.GET}
|
res |= {"data": self.request.GET, "initial": self.request.GET}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user