|
@@ -1,6 +1,6 @@
|
|
|
-from flask import render_template, Blueprint, request, redirect, url_for, flash
|
|
|
+from flask import render_template, Blueprint, request, redirect, url_for
|
|
|
import requests
|
|
|
-from collections import defaultdict
|
|
|
+from backstage.utils.routes import update_manage_table
|
|
|
|
|
|
home_app = Blueprint('home', __name__)
|
|
|
|
|
@@ -16,19 +16,5 @@ def home():
|
|
|
|
|
|
@home_app.route('/backstage/home/update', methods=['POST'])
|
|
|
def update():
|
|
|
- update_data = defaultdict(list)
|
|
|
- for key, value in request.form.items():
|
|
|
- element_type = key.split('-')[0]
|
|
|
- if element_type == 'img':
|
|
|
- value = eval(value)
|
|
|
- else:
|
|
|
- value = str(value)
|
|
|
- update_data[element_type].append(value)
|
|
|
- response = requests.post(
|
|
|
- 'http://127.0.0.1:5000/api/gen/home?section={}'.format(
|
|
|
- request.args.get('section_class')), json=update_data)
|
|
|
- if response.status_code == 200:
|
|
|
- flash('修改成功', 'success')
|
|
|
- else:
|
|
|
- flash('修改失敗', 'danger')
|
|
|
+ update_manage_table(request.form, request.args)
|
|
|
return redirect(url_for('home.home'))
|