mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-12-22 22:01:48 +01:00
Fix group creation
This commit is contained in:
parent
b929cb6cbd
commit
d37b1496bc
1 changed files with 6 additions and 2 deletions
|
@ -5,15 +5,19 @@ from party.models import Party
|
|||
|
||||
|
||||
class PartyForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.original_instance = kwargs.get("instance")
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = Party
|
||||
fields = ["name", "invited_characters"]
|
||||
|
||||
def clean_invited_characters(self):
|
||||
invited = self.cleaned_data["invited_characters"]
|
||||
if not self.instance:
|
||||
if not self.original_instance:
|
||||
return invited
|
||||
members = self.instance.characters.all()
|
||||
members = self.original_instance.characters.all()
|
||||
for character in invited:
|
||||
if character in members:
|
||||
self.add_error(
|
||||
|
|
Loading…
Reference in a new issue