fix(api): 修复 location 没有正确设置的问题
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
928d9685f2
commit
44bcd9f145
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"conventionalCommits.scopes": [
|
||||
"api"
|
||||
]
|
||||
}
|
||||
11
app.py
11
app.py
@ -26,7 +26,6 @@ GROCY_API_KEY = os.environ.get("GROCY_API_KEY")
|
||||
GROCY_PORT = os.environ.get("GROCY_PORT")
|
||||
GROCY_DEFAULT_QUANTITY_UNIT_ID = os.environ.get("GROCY_DEFAULT_QUANTITY_UNIT_ID")
|
||||
GROCY_DEFAULT_BEST_BEFORE_DAYS = os.environ.get("GROCY_DEFAULT_BEST_BEFORE_DAYS")
|
||||
GROCY_LOCATION = []
|
||||
X_RapidAPI_Key = os.environ.get("X_RapidAPI_Key")
|
||||
|
||||
app = Flask(__name__)
|
||||
@ -46,7 +45,12 @@ def add_product(dict_good, location):
|
||||
good_name = dict_good["description_cn"]
|
||||
if not good_name:
|
||||
return False
|
||||
location_map = {item['name']: item['id'] for item in GROCY_LOCATION}
|
||||
|
||||
locations = get_locations()
|
||||
if not location:
|
||||
location = locations[0]['name']
|
||||
|
||||
location_map = {item['name']: item['id'] for item in locations}
|
||||
data_grocy = {
|
||||
"name": good_name,
|
||||
"description": "",
|
||||
@ -178,9 +182,6 @@ def add():
|
||||
data = request.json
|
||||
location = data.get("location", "")
|
||||
barcode = data.get("barcode", "")
|
||||
GROCY_LOCATION = get_locations()
|
||||
if not location:
|
||||
location = GROCY_LOCATION[0]['name']
|
||||
|
||||
try:
|
||||
grocy.product_by_barcode(barcode)
|
||||
|
||||
@ -6,8 +6,8 @@ services:
|
||||
restart: always
|
||||
environment:
|
||||
- GROCY_API_KEY=your-api-key
|
||||
- GROCY_BASE_URL=https://grocy.tunpok.com
|
||||
- GROCY_BARCODE_HELPER_PORT=443
|
||||
- GROCY_URL=https://grocy.tunpok.com
|
||||
- GROCY_PORT=443
|
||||
- GROCY_DEFAULT_QUANTITY_UNIT_ID=1
|
||||
- GROCY_DEFAULT_BEST_BEFORE_DAYS=365
|
||||
ports:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user