Commit 741f3a7b authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

fixed render_template <-> redirect

parent 37e829c8
...@@ -125,7 +125,7 @@ def application_create(): ...@@ -125,7 +125,7 @@ def application_create():
elif request.method == 'POST': elif request.method == 'POST':
if request.form['appname'] == '': if request.form['appname'] == '':
flash('Application name cannot be empty.', 'danger') flash('Application name cannot be empty.', 'danger')
return render_template(request.url) return redirect(request.url)
elif request.method == 'POST': elif request.method == 'POST':
appkey = misc.rand_str(app.config['APPKEY_LENGTH']).decode('utf-8') appkey = misc.rand_str(app.config['APPKEY_LENGTH']).decode('utf-8')
secure_key = misc.gen_skey_b64(16) secure_key = misc.gen_skey_b64(16)
...@@ -138,14 +138,14 @@ def application_create(): ...@@ -138,14 +138,14 @@ def application_create():
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
res = dd.create_table_ddm(appkey) res = dd.create_table_ddm(appkey)
if not res[0]: if not res[0]:
ad.delete(appkey) ad.delete(appkey)
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
return redirect(url_for('applications')) return redirect(url_for('applications'))
...@@ -211,13 +211,13 @@ def application_add_device(appkey): ...@@ -211,13 +211,13 @@ def application_add_device(appkey):
res = dd.create_ddm(request.form['devname'], request.form['devid'], appkey, request.form['devdesc'], ddmin) res = dd.create_ddm(request.form['devname'], request.form['devid'], appkey, request.form['devdesc'], ddmin)
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
else: else:
res = data.create_table_ddm(appkey, request.form['devid']) res = data.create_table_ddm(appkey, request.form['devid'])
if not res[0]: if not res[0]:
dd.delete(session['appkey'], request.form['devid']) dd.delete(session['appkey'], request.form['devid'])
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
else: else:
return redirect(url_for('application', appkey=appkey)) return redirect(url_for('application', appkey=appkey))
...@@ -565,7 +565,7 @@ def application_settings(appkey): ...@@ -565,7 +565,7 @@ def application_settings(appkey):
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
return redirect(request.url) return redirect(request.url)
......
...@@ -86,7 +86,7 @@ def administration_user_new_application(name): ...@@ -86,7 +86,7 @@ def administration_user_new_application(name):
elif request.method == 'POST': elif request.method == 'POST':
if request.form['appname'] == '': if request.form['appname'] == '':
flash('Application name cannot be empty.', 'danger') flash('Application name cannot be empty.', 'danger')
return render_template(request.url) return redirect(request.url)
elif request.method == 'POST': elif request.method == 'POST':
appkey = misc.rand_str(app.config['APPKEY_LENGTH']).decode('utf-8') appkey = misc.rand_str(app.config['APPKEY_LENGTH']).decode('utf-8')
secure_key = misc.gen_skey_b64(16) secure_key = misc.gen_skey_b64(16)
...@@ -99,14 +99,14 @@ def administration_user_new_application(name): ...@@ -99,14 +99,14 @@ def administration_user_new_application(name):
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
res = dd.create_table_ddm(appkey) res = dd.create_table_ddm(appkey)
if not res[0]: if not res[0]:
ad.delete(appkey) ad.delete(appkey)
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
return redirect(url_for('administration_user_applications', name=name)) return redirect(url_for('administration_user_applications', name=name))
...@@ -322,7 +322,7 @@ def administration_user_application_settings(name, appkey): ...@@ -322,7 +322,7 @@ def administration_user_application_settings(name, appkey):
if not res[0]: if not res[0]:
flash('Error: {}'.format(res[1]), 'danger') flash('Error: {}'.format(res[1]), 'danger')
return render_template(request.url) return redirect(request.url)
return redirect(request.url) return redirect(request.url)
......
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