Fixed QSO editing

This commit is contained in:
Sebastian Lohff 2017-02-02 20:20:41 +01:00
parent 0bf443035d
commit 888d33cc42
1 changed files with 6 additions and 3 deletions

View File

@ -105,10 +105,13 @@ class QSOForm(forms.ModelForm):
raise forms.ValidationError("Number has to be in range of [1, 1000000]") raise forms.ValidationError("Number has to be in range of [1, 1000000]")
try: try:
QSO.objects.get(owner=self.user.id, ownNo=data) o = QSO.objects.get(owner=self.user.id, ownNo=data)
raise forms.ValidationError("You already logged a QSO with the number %s" % data) if not (self.instance and self.instance.id and self.instance.id == o.id):
raise forms.ValidationError("You already logged a QSO with the number %s" % data)
except QSO.DoesNotExist: except QSO.DoesNotExist:
return data pass
return data
def clean_otherNo(self): def clean_otherNo(self):
data = self.cleaned_data["otherNo"] data = self.cleaned_data["otherNo"]