Commit 872a37f9 by Aeolus

update

parent b01f5bd1
......@@ -102,9 +102,9 @@ def run_edit_business():
status = json_data.get("status", None)
business_model = Business.query.filter_by(id=business_id).first()
if business_name:
if business_name is not None:
business_model.business_name = business_name
if status:
if status is not None:
business_model.status = status
db.session.add(business_model)
db.session.commit()
......
......@@ -211,44 +211,44 @@ def run_edit_hatch():
left_count = json_data.get("left_count", None)
total_count = json_data.get("total_count", None)
if production_id:
if production_id is not None:
hatch.production_id = production_id
hatch.production_name = production_name
if title:
if title is not None:
hatch.title = title
if brand_id:
if brand_id is not None:
hatch.brand_id = brand_id
hatch.brand_name = brand_name
if production_type_id:
if production_type_id is not None:
hatch.production_type_id = production_type_id
hatch.production_type_name = production_type_name
if price:
if price is not None:
hatch.price = price
if original_price:
if original_price is not None:
hatch.original_price = original_price
if weight:
if weight is not None:
hatch.weight = weight
if weight_unit:
if weight_unit is not None:
hatch.weight_unit = weight_unit
if weight_error:
if weight_error is not None:
hatch.weight_error = weight_error
if expiration_date:
if expiration_date is not None:
hatch.expiration_date = expiration_date
if expiration_date_unit:
if expiration_date_unit is not None:
hatch.expiration_date_unit = expiration_date_unit
if is_expiration_date:
if is_expiration_date is not None:
hatch.is_expiration_date = is_expiration_date
if img:
if img is not None:
hatch.img = img
if tags:
if tags is not None:
hatch.tags = tags
if content:
if content is not None:
hatch.content = content
if summary:
if summary is not None:
hatch.summary = summary
if left_count:
if left_count is not None:
hatch.left_count = left_count
if total_count:
if total_count is not None:
hatch.total_count = total_count
db.session.add(hatch)
db.session.commit()
......
......@@ -149,25 +149,25 @@ def run_edit_machine():
if not machine_model:
return jsonify(MACHINE_NOT_EXIST_ERROR)
if device_id:
if device_id is not None:
machine_model.device_id = device_id
if qrcode_no:
if qrcode_no is not None:
machine_model.qrcode_no = qrcode_no
if mac:
if mac is not None:
machine_model.mac = mac
if power:
if power is not None:
machine_model.power = power
if place_id:
if place_id is not None:
machine_model.place_id = place_id
if address:
if address is not None:
machine_model.address = address
if hatch_number:
if hatch_number is not None:
machine_model.hatch_number = hatch_number
if type:
if type is not None:
machine_model.type = type
if status:
if status is not None:
machine_model.status = status
if discounts_id:
if discounts_id is not None:
machine_model.discounts_id = discounts_id
db.session.add(machine_model)
......
......@@ -111,9 +111,13 @@ def run_edit_place():
status = json_data.get("status", None)
place_model = Place.query.filter_by(id=id).first()
if place_name is not None:
place_model.place_name = place_name
if address is not None:
place_model.address = address
if parent_id is not None:
place_model.parent_id = parent_id
if status is not None:
place_model.status = status
db.session.add(place_model)
db.session.commit()
......
......@@ -172,37 +172,37 @@ def run_edit_production():
production_model = Production.query.filter_by(id=production_id).first()
if not production_model:
return jsonify(NO_PRODUCTION_ERROR)
if production_name:
if production_name is not None:
production_model.production_name = production_name
if title:
if title is not None:
production_model.title = title
if brand_id:
if brand_id is not None:
production_model.brand_id = brand_id
if production_type_id:
if production_type_id is not None:
production_model.production_type_id = production_type_id
if price:
if price is not None:
production_model.price = price
if original_price:
if original_price is not None:
production_model.original_price = original_price
if weight:
if weight is not None:
production_model.weight = weight
if weight_unit:
if weight_unit is not None:
production_model.weight_unit = weight_unit
if weight_error:
if weight_error is not None:
production_model.weight_error = weight_error
if expiration_date:
if expiration_date is not None:
production_model.expiration_date = expiration_date
if expiration_date_unit:
if expiration_date_unit is not None:
production_model.expiration_date_unit = expiration_date_unit
if is_expiration_date:
if is_expiration_date is not None:
production_model.is_expiration_date = is_expiration_date
if img:
if img is not None:
production_model.img = img
if tags:
if tags is not None:
production_model.tags = tags
if content:
if content is not None:
production_model.content = content
if summary:
if summary is not None:
production_model.summary = summary
db.session.add(production_model)
db.session.commit()
......@@ -348,11 +348,11 @@ def run_edit_brand():
brand_model = Brand.query.filter_by(id=brand_id).first()
if not brand_model:
return jsonify(NO_PRODUCTION_ERROR)
if brand_name:
if brand_name is not None:
brand_model.brand_name = brand_name
if img:
if img is not None:
brand_model.img = img
if status:
if status is not None:
brand_model.status = status
db.session.add(brand_model)
db.session.commit()
......@@ -482,9 +482,9 @@ def run_edit_production_type():
production_type_model = ProductionType.query.filter_by(id=production_type_id).first()
if not production_type_model:
return jsonify(NO_PRODUCTION_ERROR)
if production_type_name:
if production_type_name is not None:
production_type_model.production_type_name = production_type_name
if status:
if status is not None:
production_type_model.status = status
db.session.add(production_type_model)
db.session.commit()
......
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