From 888d33cc42ec840a878a736b4455000b3acc6be1 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Thu, 2 Feb 2017 20:20:41 +0100 Subject: [PATCH] Fixed QSO editing --- contest/forms.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contest/forms.py b/contest/forms.py index 818a2b2..abe0c80 100644 --- a/contest/forms.py +++ b/contest/forms.py @@ -105,10 +105,13 @@ class QSOForm(forms.ModelForm): raise forms.ValidationError("Number has to be in range of [1, 1000000]") try: - QSO.objects.get(owner=self.user.id, ownNo=data) - raise forms.ValidationError("You already logged a QSO with the number %s" % data) + o = QSO.objects.get(owner=self.user.id, ownNo=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: - return data + pass + + return data def clean_otherNo(self): data = self.cleaned_data["otherNo"]