Commit 2ef3c026 authored by Sli's avatar Sli

Fix error on accounting when no target_type specified

parent 7cb9ea40
Pipeline #939 passed with stage
in 4 minutes and 19 seconds
...@@ -304,14 +304,15 @@ class OperationForm(forms.ModelForm): ...@@ -304,14 +304,15 @@ class OperationForm(forms.ModelForm):
def clean(self): def clean(self):
self.cleaned_data = super(OperationForm, self).clean() self.cleaned_data = super(OperationForm, self).clean()
if self.cleaned_data['target_type'] == "USER": if 'target_type' in self.cleaned_data.keys():
self.cleaned_data['target_id'] = self.cleaned_data['user'].id if self.cleaned_data['target_type'] == "USER":
elif self.cleaned_data['target_type'] == "ACCOUNT": self.cleaned_data['target_id'] = self.cleaned_data['user'].id
self.cleaned_data['target_id'] = self.cleaned_data['club_account'].id elif self.cleaned_data['target_type'] == "ACCOUNT":
elif self.cleaned_data['target_type'] == "CLUB": self.cleaned_data['target_id'] = self.cleaned_data['club_account'].id
self.cleaned_data['target_id'] = self.cleaned_data['club'].id elif self.cleaned_data['target_type'] == "CLUB":
elif self.cleaned_data['target_type'] == "COMPANY": self.cleaned_data['target_id'] = self.cleaned_data['club'].id
self.cleaned_data['target_id'] = self.cleaned_data['company'].id elif self.cleaned_data['target_type'] == "COMPANY":
self.cleaned_data['target_id'] = self.cleaned_data['company'].id
return self.cleaned_data return self.cleaned_data
def save(self): def save(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment