修改了座位等级中文问题、空订单问题
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,6 +35,10 @@ def book():
|
||||
passenger[key] = request.form.get(f'passengers[{i}][{key}]')
|
||||
passengers.append(passenger)
|
||||
|
||||
if not passengers:
|
||||
flash("请至少添加一位乘客", "error")
|
||||
return redirect(url_for('index'))
|
||||
|
||||
conn = pymysql.connect(**db)
|
||||
cursor = conn.cursor()
|
||||
|
||||
@@ -85,7 +89,7 @@ def book():
|
||||
conn.rollback()
|
||||
print(e)
|
||||
flash("订票失败", "error")
|
||||
return redirect(url_for('search'))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
|
||||
@@ -12,7 +12,7 @@ def verify_user(cursor: Cursor, phone_number: str, password: str) -> str:
|
||||
record = cursor.fetchone()
|
||||
if not record:
|
||||
return "NO_USER"
|
||||
if record[0] != password:
|
||||
if record['Password'] != password:
|
||||
return "WRONG_PASSWORD"
|
||||
return "USER_VERIFIED"
|
||||
|
||||
|
||||
@@ -38,6 +38,14 @@ def order():
|
||||
"""
|
||||
cursor.execute(tickets_sql, (order_id,))
|
||||
tickets = cursor.fetchall()
|
||||
|
||||
seatClass2Chinses = {
|
||||
'First Class': '头等舱',
|
||||
'Business Class': '商务舱',
|
||||
'Economy Class': '经济舱'
|
||||
}
|
||||
for ticket in tickets:
|
||||
ticket['Seat_class'] = seatClass2Chinses[ticket['Seat_class']]
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from flask import render_template, request, g, abort, redirect, url_for
|
||||
from flask import render_template, request, g, abort, redirect, url_for, flash
|
||||
from .config import db
|
||||
from .utils import get_cities
|
||||
import pymysql
|
||||
@@ -13,6 +13,10 @@ def search():
|
||||
departure_date = request.args.get('departure-date')
|
||||
passengers = int(request.args.get('passengers', 1))
|
||||
|
||||
if not departure_city or not destination_city or not departure_date or not passengers:
|
||||
flash("请填写所有查询条件", "error")
|
||||
return render_template('search.html', cities=get_cities(), flights=[], username=g.name)
|
||||
|
||||
# Date validation
|
||||
try:
|
||||
departure_date_obj = datetime.datetime.strptime(departure_date, '%Y-%m-%d').date()
|
||||
|
||||
@@ -7,6 +7,19 @@
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}">
|
||||
<script src="{{ url_for('static', filename='js/index.js') }}" defer></script>
|
||||
<script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
var message = "";
|
||||
{% for msg in messages %}
|
||||
message += "{{ msg }}\n";
|
||||
{% endfor %}
|
||||
alert(message);
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
||||
@@ -5,6 +5,19 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>航班搜索结果</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/search.css') }}">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
var message = "";
|
||||
{% for msg in messages %}
|
||||
message += "{{ msg }}\n";
|
||||
{% endfor %}
|
||||
alert(message);
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
||||
Reference in New Issue
Block a user