diff --git a/.idea/sonarlint.xml b/.idea/sonarlint.xml new file mode 100644 index 0000000..5b670f2 --- /dev/null +++ b/.idea/sonarlint.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/party/forms.py b/src/party/forms.py index 588bfce..553845f 100644 --- a/src/party/forms.py +++ b/src/party/forms.py @@ -1,5 +1,6 @@ from django import forms from django.core.exceptions import ValidationError +from django.db.models import Q from character.models import Character from party.models import Party @@ -9,9 +10,16 @@ class PartyForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.original_instance = kwargs.get("instance") super().__init__(*args, **kwargs) - qs = Character.objects.filter(private=False) + qs = Character.objects.all() if self.original_instance: - qs = qs.union(self.original_instance.invited_characters.all()) + qs = qs.filter( + Q(private=False) + | Q( + pk__in=self.original_instance.invited_characters.all().values_list( + "pk", flat=True + ) + ) + ) self.fields["invited_characters"].queryset = qs class Meta: diff --git a/src/party/templates/party/parties_list.html b/src/party/templates/party/parties_list.html index 3ffc4c6..c1921bd 100644 --- a/src/party/templates/party/parties_list.html +++ b/src/party/templates/party/parties_list.html @@ -12,19 +12,19 @@