Commit 1f2d34c8 authored by Sebastian Lohff (DL7SBA)'s avatar Sebastian Lohff (DL7SBA) Committed by root
Browse files

Don't error out when newRef already exist, use it instead

Before this commit when a newRef was entered on user registration and
that ref already existed we errored out. Now we use exactly that
reference when it already exists.
parent 2b42f6ce
......@@ -27,8 +27,6 @@ class UpdateRefForm(forms.Form):
def clean_newRefName(self):
data = self.cleaned_data["newRefName"].strip().upper()
if Reference.objects.filter(name=data).count() > 0:
raise forms.ValidationError("Reference already exists")
return data
......@@ -38,6 +36,14 @@ class UpdateRefForm(forms.Form):
existingRef = cleaned_data.get("existingRef")
newRefName = cleaned_data.get("newRefName")
if newRefName:
ref = Reference.objects.get(name=newRefName)
self.cleaned_data['newRefName'] = None
self.cleaned_data['existingRef'] = ref
except Reference.DoesNotExist:
if existingRef and newRefName:
raise forms.ValidationError("Select an existing exchange or create a new one, not both!")
if not existingRef and not newRefName:
Supports Markdown
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