|
@@ -1,8 +1,10 @@
|
|
|
from flask import render_template, Blueprint, request, redirect, url_for, flash
|
|
|
import requests
|
|
|
-from backstage.config import PORTAL_SERVER
|
|
|
from os import path
|
|
|
from time import sleep
|
|
|
+from backstage.utils import translate
|
|
|
+from backstage.config import PORTAL_SERVER
|
|
|
+from backstage.utils.routes import remove_content
|
|
|
|
|
|
store_locations_app = Blueprint('store_locations', __name__)
|
|
|
|
|
@@ -29,6 +31,9 @@ def create():
|
|
|
imgs.append(img_src)
|
|
|
return imgs
|
|
|
|
|
|
+ def get_district_name():
|
|
|
+ return translate(title.replace('門市', '')).lower().replace(' ', '_')
|
|
|
+
|
|
|
result = []
|
|
|
idx = 1
|
|
|
for title, type_, store, hour, phone, location, parking in zip(
|
|
@@ -38,7 +43,8 @@ def create():
|
|
|
):
|
|
|
result.append({
|
|
|
'title': title, 'type': type_, 'imgs': list(get_imgs()), 'store': store,
|
|
|
- 'hour': hour, 'phone': phone, 'location': location, 'parking': parking
|
|
|
+ 'hour': hour, 'phone': phone, 'location': location, 'parking': parking,
|
|
|
+ 'url': '/{}/bhouse_store_in_{}_city'.format(type_, get_district_name())
|
|
|
})
|
|
|
idx += 1
|
|
|
response = requests.post('{}store_locations'.format(PORTAL_SERVER), json=result)
|
|
@@ -59,3 +65,9 @@ def remove_img():
|
|
|
else:
|
|
|
flash('移除照片失敗', 'danger')
|
|
|
return redirect(url_for('store_locations.main'))
|
|
|
+
|
|
|
+
|
|
|
+@store_locations_app.route('/backstage/store_locations/remove', methods=['POST'])
|
|
|
+def remove():
|
|
|
+ remove_content()
|
|
|
+ return redirect(url_for('store_locations.main'))
|