diff --git a/paas_theme/forms.py b/paas_theme/forms.py index 69e405f..54f37ef 100644 --- a/paas_theme/forms.py +++ b/paas_theme/forms.py @@ -282,7 +282,6 @@ class PersonFacetedSearchFormNew(FacetedSearchForm): wahl_vorschlag_erfolgreich = forms.ChoiceField( widget=forms.RadioSelect(), required=False, - initial="beides", label="Vorschlag erfolgreich", choices=[ ("beides", "sowohl erflogreich als auch nicht erfolgreich"), @@ -454,7 +453,7 @@ def search(self): if ( self.cleaned_data["mtgld_mitgliedschaft"] or self.cleaned_data["mtgld_klasse"] - ) and not self.cleaned_data["start_date_form"]: + ) and not (self.cleaned_data["start_date_form"] or self.cleaned_data["end_date_form"]): mtgld_dic = SQ() for mitgliedschaft in self.cleaned_data["mtgld_mitgliedschaft"]: mtgld_dic.add( diff --git a/paas_theme/models.py b/paas_theme/models.py index 6adbcff..76db9aa 100644 --- a/paas_theme/models.py +++ b/paas_theme/models.py @@ -354,17 +354,21 @@ def get_memberships( ) ) - if start and end and start > end: - raise ValueError( - f"End date needs to be before start date: {start} > {end}" - ) + if start and end: + if convert_date(start, boundary="start") > convert_date(end, boundary="end"): + raise ValueError( + f"End date needs to be before start date: {start} > {end}" + ) - if start: + if start and not end: - q_obj &= models.Q(end_date__isnull=True) | models.Q( + q_obj &= models.q(models.Q(end_date__isnull=True) | models.Q( + end_date__gte=convert_date(start, boundary="start")) + ) + elif start: + q_obj &= models.Q( end_date__gte=convert_date(start, boundary="start") ) - if start and start_exclusive: q_obj &= models.Q(start_date__gte=convert_date(start, boundary="start")) @@ -372,7 +376,7 @@ def get_memberships( q_obj &= models.Q(start_date__lte=convert_date(end, boundary="end")) if end and end_exclusive: - q_obj = models.Q(end_date__lte=convert_date(end, boundary="end")) + q_obj &= models.Q(end_date__lte=convert_date(end, boundary="end")) return self.filter(q_obj)