Skip to content

Commit

Permalink
Clean up new cluster return code
Browse files Browse the repository at this point in the history
  • Loading branch information
venatha committed Aug 23, 2016
1 parent c4ab1dc commit f3145a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/views/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ def index(self):
return render_template('clusters/index.html', page_heading='Clusters', page_title='Clusters', clusters=clusters)

def new(self):
form = ClusterForm()
return render_template('clusters/new.html', page_heading='New Cluster', page_title='New Cluster', form=form)

return self._new_cluster_return()

def post(self):
form = ClusterForm()
cluster = Cluster.query.filter_by(audit_is_deleted=False, name=form.name.data).first()
if cluster:
flash('Cluster name already in use', 'error')
return render_template('clusters/new.html', page_heading='New Cluster', page_title='New Cluster', form=form)
return self._new_cluster_return()
cluster = Cluster(name=form.name.data, is_active=True)
cluster.create()

Expand All @@ -38,3 +37,7 @@ def delete(self, cluster_id):
cluster.delete()
flash('Cluster and all associated servers deleted successfully', 'success')
return redirect(url_for('Clusters:index'))

def _new_cluster_return(self):
form = ClusterForm()
return render_template('clusters/new.html', page_heading='New Cluster', page_title='New Cluster', form=form)

0 comments on commit f3145a5

Please sign in to comment.