Commit 11c217bb by Aeolus

update

parent 74b64d39
......@@ -134,7 +134,7 @@ def add_user():
account.comment = comment
account.created_at = datetime.datetime.now()
account.updated_at = datetime.datetime.now()
if password:
if password is not None:
account.password = password
db.session.add(account)
db.session.commit()
......@@ -196,13 +196,13 @@ def get_account_detail():
@admin_route.route('/edit_account', methods=['GET', 'POST'])
def edit_user():
json_data = request.get_json()
old_phone = json_data['old_phone'] if 'old_phone' in json_data else ''
new_phone = json_data['new_phone'] if 'new_phone' in json_data else ''
user_name = json_data['user_name'] if 'user_name' in json_data else 'XX'
password = json_data['password'] if 'password' in json_data else ''
comment = json_data['comment'] if 'comment' in json_data else ''
level = json_data['level'] if 'level' in json_data else ''
status = json_data['status'] if 'status' in json_data else ''
old_phone = json_data['old_phone'] if 'old_phone' in json_data else None
new_phone = json_data['new_phone'] if 'new_phone' in json_data else None
user_name = json_data['user_name'] if 'user_name' in json_data else None
password = json_data['password'] if 'password' in json_data else None
comment = json_data['comment'] if 'comment' in json_data else None
level = json_data['level'] if 'level' in json_data else None
status = json_data['status'] if 'status' in json_data else None
if not old_phone:
return BaseResponse(error_code=-1, error_message='old phone is null')
......@@ -224,16 +224,16 @@ def edit_user():
return BaseResponse(**ACCOUNT_NOT_EXISTS_ERROR)
if level and level > g.user.level:
admin_info.level = level
if status:
if status is not None:
admin_info.status = status
if comment:
if comment is not None:
admin_info.comment = comment
if user_name:
if user_name is not None:
admin_info.user_name = user_name
if new_phone:
if new_phone is not None:
admin_info.phone = new_phone
if password:
if password is not None:
admin_info.password = password
db.session.add(admin_info)
......@@ -248,7 +248,7 @@ def edit_user():
@admin_route.route('/delete_account', methods=['GET', 'POST'])
def delete_user():
json_data = request.get_json()
phone = json_data['phone'] if 'phone' in json_data else ''
phone = json_data['phone'] if 'phone' in json_data else None
if not phone:
return BaseResponse(**PHONE_NOT_NULL_ERROR)
......
......@@ -52,7 +52,7 @@ def run_machine_list():
else:
where_sql = """ where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = '{user_id}' and admin_machine.status = 1)""".format(user_id=admin.id)
if keyword:
if keyword is not None:
where_sql += """
and CONCAT(machine.machine_no,ifnull(machine.qrcode_no,'')) LIKE '%{keyword}%'
......
......@@ -134,7 +134,7 @@ def get_place_detail():
id = json_data["id"]
place_model = Place.query.filter_by(id=id).first()
if place_model:
if place_model is not None:
return BaseResponse(data={"place_name": place_model.place_name,
"address": place_model.address,
"parent_id": place_model.parent_id,
......
......@@ -66,7 +66,7 @@ def run_rent_list():
"""
where_sql = " WHERE 0=0 "
if keyword:
if keyword is not None:
where_sql += """
and CONCAT(rent.rent_no,
wx_user.phone) LIKE '%{keyword}%'
......@@ -154,7 +154,7 @@ def get_rent_detail():
"""
where_sql = " where rent.rent_no = '{}'".format(rent_no)
if rent_detail_id:
if rent_detail_id is not None:
where_sql += " and rent_detail.id = '{}'".format(rent_detail_id)
if g.user.level != 1:
where_sql += """ and rent.business_id in (
......
Markdown is supported
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