Handle unset host/key

This commit is contained in:
David Cramer 2016-03-24 23:55:58 -07:00
parent f7d7cbd102
commit 3f411245e3
1 changed files with 6 additions and 5 deletions

View File

@ -69,11 +69,12 @@ class RedmineOptionsForm(forms.Form):
def clean(self):
cd = self.cleaned_data
client = RedmineClient(cd['host'], cd['key'])
try:
client.get_projects()
except Exception:
raise forms.ValidationError('There was an issue authenticating with Redmine')
if cd.get('host') and cd.get('key'):
client = RedmineClient(cd['host'], cd['key'])
try:
client.get_projects()
except Exception:
raise forms.ValidationError('There was an issue authenticating with Redmine')
return cd
def clean_host(self):