Open cxy-254 opened 1 week ago
I have finished in shopping.py. Before any further progress, the following tasks must be finished
[ ] Ask the user to enter user_id Entered user_id must be checked, to ensure they are in the household.json for foolproof purposes.
[ ] Create a function to insert info into the order database. chose_item() in shopping.py can be used to get item info from the supermarket.json The info returned by chose_item() and other info required need to be stored in the order.json
@Infinity0708 I updated the shopping.py
file, added a new function id_check()
. You can use this function to ask user input their house id and student id and have those ids checked as well.
def id_check():
input1 = input("Enter your house hold id please: ")
house_id_input = int(input1)
house = household_and_user.get(household.house_id == house_id_input)
if house:
print("House found! ")
input2 = input("Enter your student id: ")
student_id_input = int(input2)
student_ids = house.get("student_id", [])
if student_id_input in student_ids:
print("Student id found! ")
return house, student_ids, True
else:
return 0, 0, False
else:
print("Cannot found house or student id, check your input")
return 0, 0, False`
The return of this function is in the format of house_id, student_id, is_input_valid
. The first two variables are ints and the last one is boolean. The last id is used to indicate if the inputted ids are in the househole db.
NOTE: This function has NOT been tested yet!! This is because of the incompleteness of task 1. Thus, please keep an eye on any further updates to this function or shopping.py
.
Goal:
Loop through every order in order database (refer to the database structure created by Task1), if the ready state (e.g. isReady) of all users in an order is true, and they have enough balance to pay the order, move the order to the preparation database.
[x] Create preparation database: Store orders that are ready to be sent to the supermarket for shipping
[ ] Daily job function: For the following steps, proceed if the order meets the criteria, else continue to the next order: