Spaces:
Sleeping
Sleeping
ichieh commited on
Commit ·
f6a3340
1
Parent(s): 47dc8a7
桌次名稱為空值用預設值
Browse files
app.py
CHANGED
|
@@ -139,7 +139,7 @@ def init_db():
|
|
| 139 |
# 更新桌次
|
| 140 |
tables_data = data.get('tables', [])
|
| 141 |
print(f"- 桌次資料: {tables_data}")
|
| 142 |
-
table_names = {table['id']: table['name'] for table in tables_data}
|
| 143 |
|
| 144 |
# 檢查現有桌次
|
| 145 |
existing_tables = {table.id: table for table in Table.query.all()}
|
|
@@ -155,11 +155,11 @@ def init_db():
|
|
| 155 |
else:
|
| 156 |
table = Table(
|
| 157 |
id=i,
|
| 158 |
-
name=table_names.get(i, ''),
|
| 159 |
capacity=seats_per_table
|
| 160 |
)
|
| 161 |
db.session.add(table)
|
| 162 |
-
print(f"創建第 {i} 桌,名稱為: {table_names.get(i, '
|
| 163 |
|
| 164 |
# 刪除多餘的桌次
|
| 165 |
for table_id, table in existing_tables.items():
|
|
|
|
| 139 |
# 更新桌次
|
| 140 |
tables_data = data.get('tables', [])
|
| 141 |
print(f"- 桌次資料: {tables_data}")
|
| 142 |
+
table_names = {table['id']: table['name'].strip() if table['name'] else f'第{table["id"]}桌' for table in tables_data}
|
| 143 |
|
| 144 |
# 檢查現有桌次
|
| 145 |
existing_tables = {table.id: table for table in Table.query.all()}
|
|
|
|
| 155 |
else:
|
| 156 |
table = Table(
|
| 157 |
id=i,
|
| 158 |
+
name=table_names.get(i, f'第{i}桌'),
|
| 159 |
capacity=seats_per_table
|
| 160 |
)
|
| 161 |
db.session.add(table)
|
| 162 |
+
print(f"創建第 {i} 桌,名稱為: {table_names.get(i, f'第{i}桌')}")
|
| 163 |
|
| 164 |
# 刪除多餘的桌次
|
| 165 |
for table_id, table in existing_tables.items():
|