|
@@ -27,8 +27,6 @@ class UpdateRefForm(forms.Form):
|
27
|
27
|
|
28
|
28
|
def clean_newRefName(self):
|
29
|
29
|
data = self.cleaned_data["newRefName"].strip().upper()
|
30
|
|
- if Reference.objects.filter(name=data).count() > 0:
|
31
|
|
- raise forms.ValidationError("Reference already exists")
|
32
|
30
|
|
33
|
31
|
return data
|
34
|
32
|
|
|
@@ -38,6 +36,14 @@ class UpdateRefForm(forms.Form):
|
38
|
36
|
existingRef = cleaned_data.get("existingRef")
|
39
|
37
|
newRefName = cleaned_data.get("newRefName")
|
40
|
38
|
|
|
39
|
+ if newRefName:
|
|
40
|
+ try:
|
|
41
|
+ ref = Reference.objects.get(name=newRefName)
|
|
42
|
+ self.cleaned_data['newRefName'] = None
|
|
43
|
+ self.cleaned_data['existingRef'] = ref
|
|
44
|
+ except Reference.DoesNotExist:
|
|
45
|
+ pass
|
|
46
|
+
|
41
|
47
|
if existingRef and newRefName:
|
42
|
48
|
raise forms.ValidationError("Select an existing exchange or create a new one, not both!")
|
43
|
49
|
if not existingRef and not newRefName:
|