From 426aa7967acdf04adffda12e2944aa6b99f0adc4 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:22:40 +0000 Subject: [PATCH 01/34] Summary Description --- .DS_Store | Bin 0 -> 6148 bytes retrieveOrder.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .DS_Store create mode 100644 retrieveOrder.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e899e01735d53a85a44272d7d57af4c9818b3c1 GIT binary patch literal 6148 zcmeHKu};H441IM7ivSlC2m>& zh}U7g%vgVHEB3uE84?Tx1HnKr5DfeX1H7|UriX@MgMnZm82DsB&xb@+EFC+;e00#{ z7JxWmI17D!E^AG4EFC*Tj!?u(iB>A!Vu+P9o;( Date: Wed, 24 Jan 2024 14:31:45 +0000 Subject: [PATCH 02/34] summary comment --- GUI1.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 GUI1.py diff --git a/GUI1.py b/GUI1.py new file mode 100644 index 0000000..b497c27 --- /dev/null +++ b/GUI1.py @@ -0,0 +1,21 @@ +from tkinter import * +from tkinter.ttk import * + +main = Tk() +main.geometry('500x500') + +l1 = Label(main, text='Search by: ') +l2 = Label(main, text='Search val:') + +e1 = Entry(main) +e2 = Entry(main) + +b1 = Button(main, text='Search') + +l1.grid(row=0, column=0, sticky=W, pady=4) +l2.grid(row=1, column=0, sticky=W, pady=4) +e1.grid(row=0, column=1, sticky=E, pady=4) +e2.grid(row=1, column=1, sticky=E, pady=4) +b1.grid(row=2, column=0) + +main.mainloop() \ No newline at end of file From b44010b588c266aaf4baa900d8213a9622710ff3 Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:38:06 +0000 Subject: [PATCH 03/34] add command to button --- GUI1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI1.py b/GUI1.py index b497c27..2d9d065 100644 --- a/GUI1.py +++ b/GUI1.py @@ -10,7 +10,7 @@ e1 = Entry(main) e2 = Entry(main) -b1 = Button(main, text='Search') +b1 = Button(main, text='Search', command= get_value) l1.grid(row=0, column=0, sticky=W, pady=4) l2.grid(row=1, column=0, sticky=W, pady=4) From fadc2c0c33e2aa6e9b5eb828fe3d1b2a796f24a4 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:40:30 +0000 Subject: [PATCH 04/34] Update for overlapping data Returns list at end instead of returning singular value to allow for overlapping data --- retrieveOrder.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index ea1b3ac..0ea29d5 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -11,22 +11,25 @@ possibleSearches = ['order_id', 'date', 'restaurant', 'postcode'] +searched_orders = [] + def retrieveOrder(searchParameter, Value): for order in orders: if searchParameter == 'order_id' or searchParameter == 'date': if order.get(searchParameter) == str(Value): - return order + searched_orders.append(order) elif searchParameter == 'restaurant': restaurant = order.get('restaurant') if restaurant.get('name') == Value: - return order + searched_orders.append(order) elif searchParameter == 'postcode': address = order.get('delivery') if address.get('postcode') == Value: - return order + searched_orders.append(order) else: print('Order not in data') return 0 + return searched_orders #print(retrieveOrder('restaurant', 'Burger Bistro')) From 73d987d883459192f8eb553a3ec24cbedf4f8fea Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:46:55 +0000 Subject: [PATCH 05/34] Normalisation The text now allows for any capitalisation and any substring of a name to be searched for --- retrieveOrder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 0ea29d5..e81f192 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -16,15 +16,15 @@ def retrieveOrder(searchParameter, Value): for order in orders: if searchParameter == 'order_id' or searchParameter == 'date': - if order.get(searchParameter) == str(Value): + if order.get(searchParameter).contains(str(Value)): searched_orders.append(order) elif searchParameter == 'restaurant': restaurant = order.get('restaurant') - if restaurant.get('name') == Value: + if restaurant.get('name').contains(Value.lower()): searched_orders.append(order) elif searchParameter == 'postcode': address = order.get('delivery') - if address.get('postcode') == Value: + if address.get('postcode').contains(Value.lower()): searched_orders.append(order) else: print('Order not in data') From b9492312cd8348e424b2755dd44d2a564eb59d84 Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:53:37 +0000 Subject: [PATCH 06/34] Update GUI1.py --- GUI1.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/GUI1.py b/GUI1.py index 2d9d065..57a4b6e 100644 --- a/GUI1.py +++ b/GUI1.py @@ -4,18 +4,26 @@ main = Tk() main.geometry('500x500') + + +def get_val(): + entry_val=e2.get() + l3 = Label(main, text=entry_val) + l3.grid(row=3, column=0) + l1 = Label(main, text='Search by: ') l2 = Label(main, text='Search val:') e1 = Entry(main) e2 = Entry(main) -b1 = Button(main, text='Search', command= get_value) +b1 = Button(main, text='Search', command=get_val) l1.grid(row=0, column=0, sticky=W, pady=4) l2.grid(row=1, column=0, sticky=W, pady=4) e1.grid(row=0, column=1, sticky=E, pady=4) e2.grid(row=1, column=1, sticky=E, pady=4) -b1.grid(row=2, column=0) +b1.grid(row=2, column=0, sticky=W, pady=2) + main.mainloop() \ No newline at end of file From bd1d83e9e5ccccdf9f921a6147724292df50e6ff Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:53:50 +0000 Subject: [PATCH 07/34] Sanitisation Returning tuples instead of strings or dictionaries, the True or False at the start of a tuple indicates whether its a successful search --- retrieveOrder.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index e81f192..61516c2 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -15,7 +15,12 @@ def retrieveOrder(searchParameter, Value): for order in orders: - if searchParameter == 'order_id' or searchParameter == 'date': + if searchParameter == 'order_id': + if Value < 0: + return (False, 'Error: Value can not be below zero') + if order.get(searchParameter).contains(str(Value)): + searched_orders.append(order) + elif searchParameter == 'date': if order.get(searchParameter).contains(str(Value)): searched_orders.append(order) elif searchParameter == 'restaurant': @@ -27,9 +32,8 @@ def retrieveOrder(searchParameter, Value): if address.get('postcode').contains(Value.lower()): searched_orders.append(order) else: - print('Order not in data') - return 0 - return searched_orders + return (False, 'Error: Cannoy be found within data') + return (True, searched_orders) #print(retrieveOrder('restaurant', 'Burger Bistro')) From f71c8cf07b3c404abc1851e728d86a0500118912 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:01:53 +0000 Subject: [PATCH 08/34] Reformatted, added contact number, fixed adding to searched_orders list Changed around the code to work properly and added searching by contact_number --- retrieveOrder.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 61516c2..f871717 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -5,11 +5,12 @@ response = requests.get("https://europe-west1-inshur-dev0-service0.cloudfunctions.net/delivery-api-orders") global orders +global searched_orders orders = response.json() orders = orders['data'] -possibleSearches = ['order_id', 'date', 'restaurant', 'postcode'] +possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number'] searched_orders = [] @@ -18,24 +19,28 @@ def retrieveOrder(searchParameter, Value): if searchParameter == 'order_id': if Value < 0: return (False, 'Error: Value can not be below zero') - if order.get(searchParameter).contains(str(Value)): + if str(Value) in order.get(searchParameter): searched_orders.append(order) elif searchParameter == 'date': - if order.get(searchParameter).contains(str(Value)): + if str(Value) in order.get(searchParameter): searched_orders.append(order) elif searchParameter == 'restaurant': restaurant = order.get('restaurant') - if restaurant.get('name').contains(Value.lower()): + if Value.lower() in restaurant.get('name'): searched_orders.append(order) elif searchParameter == 'postcode': address = order.get('delivery') - if address.get('postcode').contains(Value.lower()): + if Value.lower() in address.get('postcode'): + searched_orders.append(order) + elif searchParameter == 'contact_number': + address = order.get('delivery') + if Value.lower() in address.get('contact_number'): searched_orders.append(order) else: return (False, 'Error: Cannoy be found within data') - return (True, searched_orders) + return (True, searched_orders) -#print(retrieveOrder('restaurant', 'Burger Bistro')) -#print(retrieveOrder('order_id', 8)) -#print(retrieveOrder('postcode', "BN2 5EF")) \ No newline at end of file +print(retrieveOrder('restaurant', 'Burger Bistro')) +print(retrieveOrder('order_id', 8)) +print(retrieveOrder('postcode', "BN2 5EF")) \ No newline at end of file From 7e138ca9de53a8629d25e34bb88eeb4a41033e5e Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:10:57 +0000 Subject: [PATCH 09/34] Update GUI1.py --- GUI1.py | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/GUI1.py b/GUI1.py index 57a4b6e..dad051f 100644 --- a/GUI1.py +++ b/GUI1.py @@ -4,26 +4,37 @@ main = Tk() main.geometry('500x500') +def get_val(): + entry_val=entrySearchVal.get() + labelReturnSearchVal = Label(main, text=entry_val) + labelReturnSearchVal.grid(row=3, column=0) +def show(): + labelReturnSearchBy.config(text = currentSearchBy) + labelReturnSearchBy = Label(main, text="order_id") + labelReturnSearchBy.grid(row=4, column=0) -def get_val(): - entry_val=e2.get() - l3 = Label(main, text=entry_val) - l3.grid(row=3, column=0) +#dropdown search by values +possibleSearches = ['order_id', 'date', 'restaurant', 'postcode'] + +labelSearchBy = Label(main, text='Search by: ') +labelSearchVal = Label(main, text='Search val:') + +currentSearchBy = StringVar() +currentSearchBy.set('order_id') -l1 = Label(main, text='Search by: ') -l2 = Label(main, text='Search val:') +dropSearchBy = OptionMenu(main, StringVar(), *possibleSearches) +# entrySearchBy = Entry(main) +entrySearchVal = Entry(main) -e1 = Entry(main) -e2 = Entry(main) +buttonSearch = Button(main, text='Search', command=get_val) -b1 = Button(main, text='Search', command=get_val) +labelSearchBy.grid(row=0, column=0, sticky=W, pady=4) +labelSearchVal.grid(row=1, column=0, sticky=W, pady=4) +dropSearchBy.grid(row=0, column=1, sticky=E, pady=4) +entrySearchVal.grid(row=1, column=1, sticky=E, pady=4) +buttonSearch.grid(row=2, column=0, sticky=W, pady=2) -l1.grid(row=0, column=0, sticky=W, pady=4) -l2.grid(row=1, column=0, sticky=W, pady=4) -e1.grid(row=0, column=1, sticky=E, pady=4) -e2.grid(row=1, column=1, sticky=E, pady=4) -b1.grid(row=2, column=0, sticky=W, pady=2) main.mainloop() \ No newline at end of file From 736c7ac00fc3e469da30486dac20742223c3a1dd Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:19:44 +0000 Subject: [PATCH 10/34] Update retrieveOrder.py --- retrieveOrder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index f871717..720ce9e 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -43,4 +43,5 @@ def retrieveOrder(searchParameter, Value): print(retrieveOrder('restaurant', 'Burger Bistro')) print(retrieveOrder('order_id', 8)) -print(retrieveOrder('postcode', "BN2 5EF")) \ No newline at end of file +print(retrieveOrder('postcode', "BN2 5EF")) + From 0274b8fc7d672d33199c486b96f1a2e0124ec805 Mon Sep 17 00:00:00 2001 From: Jeevan2191999 <103751884+Jeevan2191999@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:19:53 +0000 Subject: [PATCH 11/34] house number added now you can find the delivery by house number as well --- retrieveOrder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index f871717..ae818ad 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -10,7 +10,7 @@ orders = response.json() orders = orders['data'] -possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number'] +possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] searched_orders = [] @@ -36,6 +36,7 @@ def retrieveOrder(searchParameter, Value): address = order.get('delivery') if Value.lower() in address.get('contact_number'): searched_orders.append(order) + elif searchParameter == 'house_number' else: return (False, 'Error: Cannoy be found within data') return (True, searched_orders) From f831ec61943afa3e655492f123b0aa3767575094 Mon Sep 17 00:00:00 2001 From: GitGodess02 <156833343+GitGodess02@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:20:22 +0000 Subject: [PATCH 12/34] Update GUI1.py --- GUI1.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/GUI1.py b/GUI1.py index dad051f..d356f67 100644 --- a/GUI1.py +++ b/GUI1.py @@ -35,6 +35,53 @@ def show(): entrySearchVal.grid(row=1, column=1, sticky=E, pady=4) buttonSearch.grid(row=2, column=0, sticky=W, pady=2) +food_delivery = Treeview(main) +food_delivery['columns'] = ('order_id', 'date', 'restaurant_name', 'restaurant_id', 'restaurant_postcode', 'dish_id', 'dish_name', 'price', 'total_price', 'delivery_postcode', 'contact_number', 'deliver_by', 'house_number') +food_delivery.column("#0", width=0, stretch=NO) +food_delivery.column("order_id",anchor=CENTER, width=80) +food_delivery.column("date",anchor=CENTER, width=80) +food_delivery.column("restaurant_name",anchor=CENTER,width=80) +food_delivery.column("restaurant_id",anchor=CENTER,width=80) +food_delivery.column("restaurant_postcode",anchor=CENTER,width=80) +food_delivery.column("dish_id",anchor=CENTER,width=80) +food_delivery.column("dish_name",anchor=CENTER,width=80) +food_delivery.column("price",anchor=CENTER,width=80) +food_delivery.column("total_price",anchor=CENTER,width=80) +food_delivery.column("delivery_postcode",anchor=CENTER,width=80) +food_delivery.column("contact_number",anchor=CENTER,width=80) +food_delivery.column("deliver_by",anchor=CENTER,width=80) +food_delivery.column("house_number",anchor=CENTER,width=80) + +food_delivery.heading("#0",text="",anchor=CENTER) +food_delivery.heading("order_id",text="ID",anchor=CENTER) +food_delivery.heading("date",text="Date",anchor=CENTER) +food_delivery.heading("restaurant_name",text="Restaurant Name",anchor=CENTER) +food_delivery.heading("restaurant_id",text="Restaurant ID",anchor=CENTER) +food_delivery.heading("restaurant_postcode",text="Restaurant Postcode",anchor=CENTER) +food_delivery.heading("dish_id",text="Dish ID",anchor=CENTER) +food_delivery.heading("dish_name",text="Dish Name",anchor=CENTER) +food_delivery.heading("price",text="Price",anchor=CENTER) +food_delivery.heading("total_price",text="Total Price",anchor=CENTER) +food_delivery.heading("delivery_postcode",text="Delivery Postcode",anchor=CENTER) +food_delivery.heading("contact_number",text="Contact Number",anchor=CENTER) +food_delivery.heading("deliver_by",text="Deliver By",anchor=CENTER) +food_delivery.heading("house_number",text="House Number",anchor=CENTER) + + +food_delivery.insert(parent='',index='end',iid=0,text='', +values=('1','Ninja','101','Oklahoma', 'Moore')) +food_delivery.insert(parent='',index='end',iid=1,text='', +values=('2','Ranger','102','Wisconsin', 'Green Bay')) +food_delivery.insert(parent='',index='end',iid=2,text='', +values=('3','Deamon','103', 'California', 'Placentia')) +food_delivery.insert(parent='',index='end',iid=3,text='', +values=('4','Dragon','104','New York' , 'White Plains')) +food_delivery.insert(parent='',index='end',iid=4,text='', +values=('5','CrissCross','105','California', 'San Diego')) +food_delivery.insert(parent='',index='end',iid=5,text='', +values=('6','ZaqueriBlack','106','Wisconsin' , 'TONY')) + +food_delivery.grid(row= 5, column= 0, rowspan=3) main.mainloop() \ No newline at end of file From d0fe421a655d16e068d93afe124586f952200cf3 Mon Sep 17 00:00:00 2001 From: Jeevan2191999 <103751884+Jeevan2191999@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:25:38 +0000 Subject: [PATCH 13/34] added house number now you can find delivery with house number as well --- retrieveOrder.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 7ba0b44..9411244 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -36,7 +36,11 @@ def retrieveOrder(searchParameter, Value): address = order.get('delivery') if Value.lower() in address.get('contact_number'): searched_orders.append(order) - elif searchParameter == 'house_number' + elif searchParameter == 'house_number': + address = order.get('delivery') + if Value.lower() in address.get('house_number') + searched_orders.append('delivery') + #test else: return (False, 'Error: Cannoy be found within data') return (True, searched_orders) @@ -44,5 +48,4 @@ def retrieveOrder(searchParameter, Value): print(retrieveOrder('restaurant', 'Burger Bistro')) print(retrieveOrder('order_id', 8)) -print(retrieveOrder('postcode', "BN2 5EF")) - +print(retrieveOrder('postcode', "BN2 5EF")) \ No newline at end of file From 70b4d6ce8409a779afc038ae38b5c27acfcf6fe7 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:26:44 +0000 Subject: [PATCH 14/34] bugfix Added colon --- retrieveOrder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 9411244..0735caf 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -38,7 +38,7 @@ def retrieveOrder(searchParameter, Value): searched_orders.append(order) elif searchParameter == 'house_number': address = order.get('delivery') - if Value.lower() in address.get('house_number') + if Value.lower() in address.get('house_number'): searched_orders.append('delivery') #test else: From f2a25239d5899e63c36ea1c309a64ccb8fd08e89 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:30:48 +0000 Subject: [PATCH 15/34] Comments Added comments to explain the data a little bit --- retrieveOrder.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 0735caf..91972e5 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -6,21 +6,28 @@ response = requests.get("https://europe-west1-inshur-dev0-service0.cloudfunctions.net/delivery-api-orders") global orders global searched_orders +#Both global variables to allow for larger scope orders = response.json() orders = orders['data'] +#Takes the successful orders from the JSON file and adds them to a dictionary possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] +#List of possible searches, not used in the code at all mainly for frontend +#Searched_orders the list that contains all orders that match the search criteria searched_orders = [] def retrieveOrder(searchParameter, Value): for order in orders: if searchParameter == 'order_id': if Value < 0: + #Does not allow for a value ID of less than zero return (False, 'Error: Value can not be below zero') + #Returns tuple, the false is for identifying when there is an error string if str(Value) in order.get(searchParameter): searched_orders.append(order) + #The order is added to the searched_orders list when it is successful elif searchParameter == 'date': if str(Value) in order.get(searchParameter): searched_orders.append(order) @@ -30,6 +37,7 @@ def retrieveOrder(searchParameter, Value): searched_orders.append(order) elif searchParameter == 'postcode': address = order.get('delivery') + #Retrieves address first as there is a nested dictionary, repeated later if Value.lower() in address.get('postcode'): searched_orders.append(order) elif searchParameter == 'contact_number': @@ -40,12 +48,14 @@ def retrieveOrder(searchParameter, Value): address = order.get('delivery') if Value.lower() in address.get('house_number'): searched_orders.append('delivery') - #test else: return (False, 'Error: Cannoy be found within data') return (True, searched_orders) + #Ff there is not false return then the true return along with a list of all searched orders is returned + +#Tests print(retrieveOrder('restaurant', 'Burger Bistro')) print(retrieveOrder('order_id', 8)) print(retrieveOrder('postcode', "BN2 5EF")) \ No newline at end of file From 1ae12b7799051ade24c20457fb2fcc6cea1f730a Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:42:55 +0000 Subject: [PATCH 16/34] new change --- GUI1.py | 36 +++++++++++++--------- __pycache__/retrieveOrder.cpython-311.pyc | Bin 0 -> 2898 bytes 2 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 __pycache__/retrieveOrder.cpython-311.pyc diff --git a/GUI1.py b/GUI1.py index d356f67..51d6e1f 100644 --- a/GUI1.py +++ b/GUI1.py @@ -1,21 +1,25 @@ from tkinter import * from tkinter.ttk import * +import retrieveOrder as retrieve + main = Tk() -main.geometry('500x500') +# main.geometry('1000x1000') +width, height = main.winfo_screenwidth(), main.winfo_screenheight() + +main.geometry('%dx%d+0+0' % (width,height)) + +def search(): + searchBy=dropSearchBy.get() + searchVal=entrySearchVal.get() + output = retrieve.retrieveOrder(searchBy, searchVal) #searchParameter, Value) + labelOutput.config(text=output) + -def get_val(): - entry_val=entrySearchVal.get() - labelReturnSearchVal = Label(main, text=entry_val) - labelReturnSearchVal.grid(row=3, column=0) -def show(): - labelReturnSearchBy.config(text = currentSearchBy) - labelReturnSearchBy = Label(main, text="order_id") - labelReturnSearchBy.grid(row=4, column=0) #dropdown search by values -possibleSearches = ['order_id', 'date', 'restaurant', 'postcode'] +possibleSearches = ['order_id', 'order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] labelSearchBy = Label(main, text='Search by: ') labelSearchVal = Label(main, text='Search val:') @@ -24,16 +28,18 @@ def show(): currentSearchBy.set('order_id') dropSearchBy = OptionMenu(main, StringVar(), *possibleSearches) -# entrySearchBy = Entry(main) entrySearchVal = Entry(main) -buttonSearch = Button(main, text='Search', command=get_val) +buttonSearch = Button(main, text='Search', command=search) + +labelOutput = Label(main, text='no output yet') labelSearchBy.grid(row=0, column=0, sticky=W, pady=4) labelSearchVal.grid(row=1, column=0, sticky=W, pady=4) -dropSearchBy.grid(row=0, column=1, sticky=E, pady=4) -entrySearchVal.grid(row=1, column=1, sticky=E, pady=4) +dropSearchBy.grid(row=0, column=1, sticky=W, pady=4) +entrySearchVal.grid(row=1, column=1, sticky=W, pady=4) buttonSearch.grid(row=2, column=0, sticky=W, pady=2) +labelOutput.grid(row=3, column=0, sticky=W, pady=2) food_delivery = Treeview(main) food_delivery['columns'] = ('order_id', 'date', 'restaurant_name', 'restaurant_id', 'restaurant_postcode', 'dish_id', 'dish_name', 'price', 'total_price', 'delivery_postcode', 'contact_number', 'deliver_by', 'house_number') @@ -83,5 +89,5 @@ def show(): food_delivery.insert(parent='',index='end',iid=5,text='', values=('6','ZaqueriBlack','106','Wisconsin' , 'TONY')) -food_delivery.grid(row= 5, column= 0, rowspan=3) +food_delivery.grid(row= 5, column= 0, columnspan=10) main.mainloop() \ No newline at end of file diff --git a/__pycache__/retrieveOrder.cpython-311.pyc b/__pycache__/retrieveOrder.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..455c2018be604878119ccfd3096f1a516d4f7fca GIT binary patch literal 2898 zcmc&$|8LVq6hAw$lg4!uzEeiQYNv{}B<+fT3Cg~(@xO^#83NA?8wq0OO+~3)5LztgeDDs+MSzZ&G@nnP3-yI`QG`x zcOT!~dv_0HIR+^GlKLLqrmY{D&?2$fc%pCs+yM|kE(>PZo6mANeun2*JCqIO!ZYEZ z&1Hodfd@#KZ`lGEUZvKLXxX5d2#Qo&LdScRN{`w-YLq0}0)RqqTTr8O0E+jynXWmY z#$ef9 zXhXD+inUDfVup~sb!>DL+1SjZ;XmKoQA-t$-Xe^~=O&eaf4UOog zVWkX2Mj^`TiwGBzYFVW<*yNc5wDd`*Wz5AtJ}x>jwh8pMz0O^awIM1GHE z8bsB|HN(!$BJ6i(Oxr?DNo!9Pg)h(&qUFhOm@PS>%@$3975-Cxi7(M@un^ebvn3Al z3xNU-(G3uq283BRsl;_oeu=Mc9;>AWN}yA35#T+fy@3FzQY_C?iSM-HK;;s}7H(pD z|9?gD4Mid}kz9V+e?y`350*kaC~@;_4Fc*6h*Idqvj@daFRwj&4T?F^#C+wYn4_Je zErnl+Is6jLkxnnKi+P2sd`wYyy&=?H{~794iaPd&P{&>eHT=sub2R!Z9F1{l8o=(& z(RrPx$xoibEMPH^MmH3e4KLGlC^pk$$RgMe%^~8)H&QTy z*P5S1HJ?WY^aY9o;US@=aZ$w-1VI?H4CV`g`Ubp+3L(v_mc=4dVf5^hb}W5`CT%M{ zujX`=zF?q9OtW-)($wr6GKiHvqm#4tY?>e~!&1FImmx{07Lo+1xulxLh+rKpq6;jc zr}70~?&!hnyxT#G^&34p%V2HGt_IjAe8~M8)XPF$+H-flCLM631NHd!l^eGU%Z2q_ zlTN@t#kZ~;zE!Lg?_Rlg_1mk}&)vSGUf)qC&Uh`c|A)k2EiqWN-9*w$B%MU^_jP%1 zRjkQ_jy$;buZ`=}xVt7FbmW8e-hKCazwNC~xV>Xu@7VIWdVJ5aUHRF;)na3M;)o(3HLvttG^K-Mfs$S=MYv->U3k9L8v`u zkrTvBF>-QhTseH|^pNa_=PlFl_vY*@(ev2U=&sd`xs;VrF@hQ?J68QD zMmKDFX|V8?rfB8q%>&^$6BG0fVd=A3G#%VzsP$GhEZdyEkjJ_~zN3dV>)K7LXVHnA z3GFO;55G-CcIUHxrd1=vaa0A<-Uut)Km)X^^BmyB zvQW;Ib1UboqpmpaiQ_Ife LV8m&0FcE(MvKolM literal 0 HcmV?d00001 From b4af9bd96a15e1691bb1bf9d1610f11626af9967 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:57:16 +0000 Subject: [PATCH 17/34] Update GUI1.py --- GUI1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GUI1.py b/GUI1.py index d356f67..7f1f0d4 100644 --- a/GUI1.py +++ b/GUI1.py @@ -84,4 +84,5 @@ def show(): values=('6','ZaqueriBlack','106','Wisconsin' , 'TONY')) food_delivery.grid(row= 5, column= 0, rowspan=3) -main.mainloop() \ No newline at end of file +main.mainloop() + From 9df0e91fb7734368a5c9bb90d3e81872d61ee84f Mon Sep 17 00:00:00 2001 From: Jeevan2191999 <103751884+Jeevan2191999@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:58:00 +0000 Subject: [PATCH 18/34] made an update with dish id try to run this --- retrieveOrder.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 9411244..e822788 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -10,7 +10,7 @@ orders = response.json() orders = orders['data'] -possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] +possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number', 'dish_id'] searched_orders = [] @@ -38,9 +38,12 @@ def retrieveOrder(searchParameter, Value): searched_orders.append(order) elif searchParameter == 'house_number': address = order.get('delivery') - if Value.lower() in address.get('house_number') + if Value.lower() in address.get('house_number'): searched_orders.append('delivery') - #test + elif searchParameter == 'dish_id': + address = order.get('delivery') + if Value.lower() in address.get('dish_id'): + searched_orders.append.get('dish_id') else: return (False, 'Error: Cannoy be found within data') return (True, searched_orders) @@ -48,4 +51,5 @@ def retrieveOrder(searchParameter, Value): print(retrieveOrder('restaurant', 'Burger Bistro')) print(retrieveOrder('order_id', 8)) -print(retrieveOrder('postcode', "BN2 5EF")) \ No newline at end of file +print(retrieveOrder('postcode', "BN2 5EF")) +print(retrieveOrder('dish_id', '13123')) \ No newline at end of file From c7a6c0b3fd127e96c5c2cce7f748d7a8cd75727f Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:59:32 +0000 Subject: [PATCH 19/34] Cast help Fixes string error when passing in with tkinter --- retrieveOrder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 91972e5..5abf816 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -21,7 +21,7 @@ def retrieveOrder(searchParameter, Value): for order in orders: if searchParameter == 'order_id': - if Value < 0: + if int(Value) < 0: #Does not allow for a value ID of less than zero return (False, 'Error: Value can not be below zero') #Returns tuple, the false is for identifying when there is an error string From f345d8b6a7dbf445e8c2721ce87a01622117824c Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:05:17 +0000 Subject: [PATCH 20/34] Update retrieveOrder.py --- retrieveOrder.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 4a85715..73bb2e8 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -12,12 +12,7 @@ orders = orders['data'] #Takes the successful orders from the JSON file and adds them to a dictionary -<<<<<<< HEAD possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number', 'dish_id'] -======= -possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] -#List of possible searches, not used in the code at all mainly for frontend ->>>>>>> e7253d78edadf48b6aaa635043ac4db73c8c88a5 #Searched_orders the list that contains all orders that match the search criteria searched_orders = [] @@ -52,13 +47,10 @@ def retrieveOrder(searchParameter, Value): address = order.get('delivery') if Value.lower() in address.get('house_number'): searched_orders.append('delivery') -<<<<<<< HEAD elif searchParameter == 'dish_id': address = order.get('delivery') if Value.lower() in address.get('dish_id'): searched_orders.append.get('dish_id') -======= ->>>>>>> e7253d78edadf48b6aaa635043ac4db73c8c88a5 else: return (False, 'Error: Cannoy be found within data') return (True, searched_orders) From 1ea1aacac668f4d5b28da62f27e65f6d16f2cf8f Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:05:49 +0000 Subject: [PATCH 21/34] new --- GUI1.py | 10 +++++++--- __pycache__/retrieveOrder.cpython-311.pyc | Bin 2898 -> 2898 bytes 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/GUI1.py b/GUI1.py index 51d6e1f..f1de4a8 100644 --- a/GUI1.py +++ b/GUI1.py @@ -9,11 +9,15 @@ main.geometry('%dx%d+0+0' % (width,height)) +searchBy = 'order_id' +def callback(selection): + searchBy = selection + def search(): - searchBy=dropSearchBy.get() searchVal=entrySearchVal.get() output = retrieve.retrieveOrder(searchBy, searchVal) #searchParameter, Value) - labelOutput.config(text=output) + print(currentSearchBy.get()) + print(output) @@ -27,7 +31,7 @@ def search(): currentSearchBy = StringVar() currentSearchBy.set('order_id') -dropSearchBy = OptionMenu(main, StringVar(), *possibleSearches) +dropSearchBy = OptionMenu(main, currentSearchBy, *possibleSearches, command=callback) entrySearchVal = Entry(main) buttonSearch = Button(main, text='Search', command=search) diff --git a/__pycache__/retrieveOrder.cpython-311.pyc b/__pycache__/retrieveOrder.cpython-311.pyc index 455c2018be604878119ccfd3096f1a516d4f7fca..b66ee3ec7f48236af802160c63f324716d3b6054 100644 GIT binary patch delta 19 Zcmca4c1etDIWI340}zzxZ{+ge1^_b>1Xln6 delta 19 Zcmca4c1etDIWI340}#B@+sNg?4FEOK1k3;c From 875a01549fb183e786e11b6aaf89ace26f3d7ce8 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:10:46 +0000 Subject: [PATCH 22/34] Removed dishID Logic too different --- __pycache__/retrieveOrder.cpython-39.pyc | Bin 0 -> 1449 bytes retrieveOrder.py | 6 +----- 2 files changed, 1 insertion(+), 5 deletions(-) create mode 100644 __pycache__/retrieveOrder.cpython-39.pyc diff --git a/__pycache__/retrieveOrder.cpython-39.pyc b/__pycache__/retrieveOrder.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2ce91a91836257e5a266dff566ec7c06045f64df GIT binary patch literal 1449 zcmZux&5j#I5bmBI&v^W^NfZ%494y4eC|+k1!68CXwE2P463M_}B(!Qzmpzjm&rGU& zyt3t-HV+VSKpbsu9C-=EGt8A!UH~B^B&uhi)XEs;RE78qw(ljGob_Kf_=HazseTeA%lzV@a2 z9?erG8$a@}Ib|Y{p7dX_umx>s$)*f0tP9Rrjast3gF3RigAU}iOCC7xY$Xb zSME0=ErAvd1p=dZ`7GADQ1^#JC^0W!a1Kfz4U$a7B@QIa?+g^+Jc;1WVU*^joRnFl zlRQ(08R(&eG?@b~2BJs?IZ8lPIZ|lR_bR`}r-`h0pbC&&ixNeqE5FEMSNwuY z>x|(?lyQ5+v}JZy*4kdN4WBc7sGYUDvNn{>7Y^AuWEcOBHQ8gi#QMQ_k?w}Sv{!uH z*szsNxKVrkevj`F|JR!D6W`hL9pZa6|Cc>}llXtUmEWxSzwhybGwU_S+i$f9j0I_9 zV}EErGNRW8jgfoJ`CBeOiY8RS99!s7;??%W&L8!%Xe^ek8Ii zUl^y8yv$_pJkfEI^-Q^aMfKL$)}NhFf!Ru9Wlup@2bYBo@^q_jh@yZ@RxSkw*muJ% z&_5F+|Xqz#P6b4Rcs5s?L9QZqh5%0}_k}+~;kpVcj6< zbCQIEtJ&=Sg9F;XN%(T^5*yzo4|V*@&T&a`V(&PiwB+^8y)oIZuVCpNpWN+z^5kiq z_s~7McXan&zY{voRi1?(%*s?J1?CZ*Kgp(tDi#Pb(u)GrWu`0yw8>lOBfKc7$rWDT zLRHY00 Date: Wed, 24 Jan 2024 16:12:59 +0000 Subject: [PATCH 23/34] Update retrieveOrder.cpython-39.pyc --- __pycache__/retrieveOrder.cpython-39.pyc | Bin 1449 -> 1370 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/__pycache__/retrieveOrder.cpython-39.pyc b/__pycache__/retrieveOrder.cpython-39.pyc index 2ce91a91836257e5a266dff566ec7c06045f64df..a3bb8318e421bc09aca5b21845f5920497f9a535 100644 GIT binary patch delta 232 zcmZ3GNFoP!VWD(}*$<@pg8AT@Z zvZOPbO)h0IV`buCEE1c%gGHb77JEu&aYlS*%H%gJZtna*E221xQi}`n^NLf8c!1nn z0tNZS#hFPtsllm delta 312 zcmYLCOHRWu5cN1ViIO^egxcN!HJh@bOEy$+fQStUp|&<8eA+OMScN;Z@*0sWSytSD zJFv-Jkgy99Gn#pNGxO%P;d>+|LWIOdI$EpmwKxFq%@K@;tuJ$(UFUK}-TE)MMOP=b zGy)+d8IvVkO+VhC2j^MIYA%BYfIP8^$mpIf0jCwMJ=tmCg;h{*HKbyeM-4n%DO$}P z|K&~vM2gg+j7xSyQ!>~#U-Ytrk#%f&UaCiJ4!sq0&8K$@$0lJT0in%(h-m=WH;N7U z=G?rp)3aTxy9iL}VlmeWWA|pKSZJM3A5^L)ILnmAJv+w!#-hM{USih`{#(x^eBdWB GxcmXLheg}~ From f58062f39855c1249531b22668561d8908e0578c Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:14:17 +0000 Subject: [PATCH 24/34] s --- GUI1.py | 2 +- __pycache__/retrieveOrder.cpython-311.pyc | Bin 2898 -> 3021 bytes retrieveOrder.py | 6 +----- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/GUI1.py b/GUI1.py index b5f36ea..ca359b2 100644 --- a/GUI1.py +++ b/GUI1.py @@ -15,7 +15,7 @@ def callback(selection): def search(): searchVal=entrySearchVal.get() - output = retrieve.retrieveOrder(searchBy, searchVal) #searchParameter, Value) + output = retrieve.retrieveOrder(currentSearchBy.get(), searchVal) #searchParameter, Value) print(currentSearchBy.get()) print(output) diff --git a/__pycache__/retrieveOrder.cpython-311.pyc b/__pycache__/retrieveOrder.cpython-311.pyc index b66ee3ec7f48236af802160c63f324716d3b6054..4698c91772e65b4da7a44770ad54f1561915e55b 100644 GIT binary patch delta 639 zcmca4c2=BsIWI340}x1?Z%oaZ$ScX{wNYK3ak2~}Co^9P|HOZCY$=Sv44MLyeHhQG zxv(%WOlK$osfPj=h6zlu{IyIq3@MD+Od!Fc(8+;JGD0a#*7)dEQ)E9;9sC_c9>J)y63V&bW4I=C^EU61yiq@$OOio2%vUOg4%UiacJKR z)Xqgv`(q64ARo?U6%b$qhIbDiFi5$B8B%ykI3`=NP2pp|#g<=`l3G-Ji#ao|Wb!q( zBV1CzpcMh);@^{(uq*Q4TZlX-=wLkvfpe2*kzA vjFVHi%7Nj3hbvqC1_NsYYeQ~B?gY;nreo2gXIWI340}zzxZ%pl)$ScXHuu)x}adH78D6c(r{_QdHCoCegx3e^)*!?XZohv?)(%wmkJlY3djnVF#?94sQ( zZ58|gG=UvzLMYS(ZLn@hu!}_}@4=y0NMr(Ik2g>|CtmGEtk|svYhMP`&V^UI1{ Date: Wed, 24 Jan 2024 16:19:15 +0000 Subject: [PATCH 25/34] latest --- GUI1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GUI1.py b/GUI1.py index ca359b2..287a8a9 100644 --- a/GUI1.py +++ b/GUI1.py @@ -18,6 +18,7 @@ def search(): output = retrieve.retrieveOrder(currentSearchBy.get(), searchVal) #searchParameter, Value) print(currentSearchBy.get()) print(output) + labelOutput.config(text=output) @@ -36,7 +37,7 @@ def search(): buttonSearch = Button(main, text='Search', command=search) -labelOutput = Label(main, text='no output yet') +labelOutput = Label(main, text='no output yet', wraplength=1000) labelSearchBy.grid(row=0, column=0, sticky=W, pady=4) labelSearchVal.grid(row=1, column=0, sticky=W, pady=4) From f6144eae4e305794dde7b686ccf8283f912949a1 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:20:53 +0000 Subject: [PATCH 26/34] Fixed excessive adding to dicitonary Change in to == --- retrieveOrder.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 3b34739..6916a12 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -24,7 +24,7 @@ def retrieveOrder(searchParameter, Value): #Does not allow for a value ID of less than zero return (False, 'Error: Value can not be below zero') #Returns tuple, the false is for identifying when there is an error string - if str(Value) in order.get(searchParameter): + if str(Value) == order.get(searchParameter): searched_orders.append(order) #The order is added to the searched_orders list when it is successful elif searchParameter == 'date': @@ -55,7 +55,4 @@ def retrieveOrder(searchParameter, Value): #Tests -print(retrieveOrder('restaurant', 'Burger Bistro')) -print(retrieveOrder('order_id', 8)) -print(retrieveOrder('postcode', "BN2 5EF")) -print(retrieveOrder('dish_id', '13123')) \ No newline at end of file +print(retrieveOrder('order_id', 1)) \ No newline at end of file From 5aa49132a7b7bf2454bcb09b16f39d7bd17dd128 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:23:49 +0000 Subject: [PATCH 27/34] Removed test --- retrieveOrder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 6916a12..82a8498 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -54,5 +54,4 @@ def retrieveOrder(searchParameter, Value): -#Tests -print(retrieveOrder('order_id', 1)) \ No newline at end of file +#Tests \ No newline at end of file From 7bf67bb88ead4ec0d5d4971e0d5aa3f2143c0354 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:29:08 +0000 Subject: [PATCH 28/34] Fixed the one sided capital letter normalisation --- retrieveOrder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/retrieveOrder.py b/retrieveOrder.py index 82a8498..1fd3314 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -32,12 +32,12 @@ def retrieveOrder(searchParameter, Value): searched_orders.append(order) elif searchParameter == 'restaurant': restaurant = order.get('restaurant') - if Value.lower() in restaurant.get('name'): + if Value.lower() in restaurant.get('name').lower(): searched_orders.append(order) elif searchParameter == 'postcode': address = order.get('delivery') #Retrieves address first as there is a nested dictionary, repeated later - if Value.lower() in address.get('postcode'): + if Value.lower() in address.get('postcode').lower(): searched_orders.append(order) elif searchParameter == 'contact_number': address = order.get('delivery') @@ -54,4 +54,6 @@ def retrieveOrder(searchParameter, Value): -#Tests \ No newline at end of file +#Tests + +print(retrieveOrder('restaurant', 'Burger')) \ No newline at end of file From 38bc3ce5df07b360bad9c58033077c34e8f48798 Mon Sep 17 00:00:00 2001 From: jamiesage <58664883+jamiesage@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:34:28 +0000 Subject: [PATCH 29/34] new --- GUI1.py | 23 +++++++--------------- __pycache__/retrieveOrder.cpython-311.pyc | Bin 3021 -> 2866 bytes retrieveOrder.py | 12 +++++------ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/GUI1.py b/GUI1.py index 287a8a9..f3f0a75 100644 --- a/GUI1.py +++ b/GUI1.py @@ -16,10 +16,15 @@ def callback(selection): def search(): searchVal=entrySearchVal.get() output = retrieve.retrieveOrder(currentSearchBy.get(), searchVal) #searchParameter, Value) - print(currentSearchBy.get()) + # print(currentSearchBy.get()) print(output) - labelOutput.config(text=output) + # labelOutput.config(text=output) + # if output[0] == 0 + + food_delivery.insert(parent='',index='end',iid=0,text='', + values=('1','05-01-2023','101','Burger Bisto', '61340', 'BN2 9US', '16675', 'Classic Cheeseburger', '7.99', '92493', 'Sweet Potato Fries', '3.99', '11,98', 'BN2 5EF', '072442766728', '05-01-2023T19:45:00', '12')) + food_delivery.redraw() @@ -80,20 +85,6 @@ def search(): food_delivery.heading("deliver_by",text="Deliver By",anchor=CENTER) food_delivery.heading("house_number",text="House Number",anchor=CENTER) - -food_delivery.insert(parent='',index='end',iid=0,text='', -values=('1','Ninja','101','Oklahoma', 'Moore')) -food_delivery.insert(parent='',index='end',iid=1,text='', -values=('2','Ranger','102','Wisconsin', 'Green Bay')) -food_delivery.insert(parent='',index='end',iid=2,text='', -values=('3','Deamon','103', 'California', 'Placentia')) -food_delivery.insert(parent='',index='end',iid=3,text='', -values=('4','Dragon','104','New York' , 'White Plains')) -food_delivery.insert(parent='',index='end',iid=4,text='', -values=('5','CrissCross','105','California', 'San Diego')) -food_delivery.insert(parent='',index='end',iid=5,text='', -values=('6','ZaqueriBlack','106','Wisconsin' , 'TONY')) - food_delivery.grid(row= 5, column= 0, rowspan=3) main.mainloop() diff --git a/__pycache__/retrieveOrder.cpython-311.pyc b/__pycache__/retrieveOrder.cpython-311.pyc index 4698c91772e65b4da7a44770ad54f1561915e55b..16bd033aabbe11c3d53f7f9706a3ea72df09d2f0 100644 GIT binary patch delta 351 zcmX>rzDbO4IWI340}%YS+L-#Ab0VJv(;0?|8mA@~FtRdoO)g_Rt1*d%fnhpB2}ltX zxG+p$iZ!ccs$ocB%w_@!7KN8EPgZ1>n%v41!U`6ee1^rGsV8BwFmosGQlLVJC__>D z_Y0t^*N12q5uK#gQi delta 506 zcmdlac2=BkIWI340}x1?Z%obMn#d=?r5U`99 z$OB>sU}S)+!_n+*=Aw5}xqloPSzZnos4&acS ze3ZkG@xo+2AnO1J%VY)4z2;TCPNhZZsYMD-nZ+eV`9*9%$G+qM5=ERqqKe(g&q%@4 z)$JC0N@j6Jd}himRzqV$Bjd?WIeWO(fhs_OR?N&exrVE^)`yXSk*$HXA-5rSg3ki| zi)=<$*o-bR7++y9zQAC7gMk$)=e2RU%2ybaFEA)0%W+<0)4IZ@b&)~) j3WN3q25p3#=Zx};Z0c9o)Gsnt2HP diff --git a/retrieveOrder.py b/retrieveOrder.py index 3b34739..1fd3314 100644 --- a/retrieveOrder.py +++ b/retrieveOrder.py @@ -24,7 +24,7 @@ def retrieveOrder(searchParameter, Value): #Does not allow for a value ID of less than zero return (False, 'Error: Value can not be below zero') #Returns tuple, the false is for identifying when there is an error string - if str(Value) in order.get(searchParameter): + if str(Value) == order.get(searchParameter): searched_orders.append(order) #The order is added to the searched_orders list when it is successful elif searchParameter == 'date': @@ -32,12 +32,12 @@ def retrieveOrder(searchParameter, Value): searched_orders.append(order) elif searchParameter == 'restaurant': restaurant = order.get('restaurant') - if Value.lower() in restaurant.get('name'): + if Value.lower() in restaurant.get('name').lower(): searched_orders.append(order) elif searchParameter == 'postcode': address = order.get('delivery') #Retrieves address first as there is a nested dictionary, repeated later - if Value.lower() in address.get('postcode'): + if Value.lower() in address.get('postcode').lower(): searched_orders.append(order) elif searchParameter == 'contact_number': address = order.get('delivery') @@ -55,7 +55,5 @@ def retrieveOrder(searchParameter, Value): #Tests -print(retrieveOrder('restaurant', 'Burger Bistro')) -print(retrieveOrder('order_id', 8)) -print(retrieveOrder('postcode', "BN2 5EF")) -print(retrieveOrder('dish_id', '13123')) \ No newline at end of file + +print(retrieveOrder('restaurant', 'Burger')) \ No newline at end of file From 8f40b8ecae5d5f3f3c6c9b18f914332aad831ecd Mon Sep 17 00:00:00 2001 From: GitGodess02 <156833343+GitGodess02@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:39:42 +0000 Subject: [PATCH 30/34] Update retrieveOrder.cpython-311.pyc --- __pycache__/retrieveOrder.cpython-311.pyc | Bin 2866 -> 2857 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/__pycache__/retrieveOrder.cpython-311.pyc b/__pycache__/retrieveOrder.cpython-311.pyc index 16bd033aabbe11c3d53f7f9706a3ea72df09d2f0..101e2a0a3f5ce0b06676662331b134bf683a4908 100644 GIT binary patch delta 40 ucmdlawo;61IWI340}$lfY~*rh=l5{7iU}=FEh>(2Ov%m6+nmXMk{JNc>I;Ve delta 49 zcmZ1}wn>a@IWI340}%YS+Q{Y3E)ke)6%$&VT2vg9m6)5E8sndr>Qa Date: Wed, 24 Jan 2024 16:53:45 +0000 Subject: [PATCH 31/34] latestnew --- GUI1.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/GUI1.py b/GUI1.py index f3f0a75..b48394b 100644 --- a/GUI1.py +++ b/GUI1.py @@ -18,13 +18,19 @@ def search(): output = retrieve.retrieveOrder(currentSearchBy.get(), searchVal) #searchParameter, Value) # print(currentSearchBy.get()) print(output) - # labelOutput.config(text=output) + labelOutput.config(text=output) - # if output[0] == 0 + # for order in output: + # if output[0] == False: + # labelOutput.config(text="ERROR in input") + # else: + # labelOutput.config(text=output) + # for key, value in output.items(): + # print(key) + # print(value) food_delivery.insert(parent='',index='end',iid=0,text='', values=('1','05-01-2023','101','Burger Bisto', '61340', 'BN2 9US', '16675', 'Classic Cheeseburger', '7.99', '92493', 'Sweet Potato Fries', '3.99', '11,98', 'BN2 5EF', '072442766728', '05-01-2023T19:45:00', '12')) - food_delivery.redraw() @@ -42,7 +48,7 @@ def search(): buttonSearch = Button(main, text='Search', command=search) -labelOutput = Label(main, text='no output yet', wraplength=1000) +labelOutput = Label(main, text='no errors', wraplength=1000) labelSearchBy.grid(row=0, column=0, sticky=W, pady=4) labelSearchVal.grid(row=1, column=0, sticky=W, pady=4) From a9d318fb899971afed63d2c6b5892ab6d59d4b13 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:54:59 +0000 Subject: [PATCH 32/34] 1 1 --- GUI1.py | 2 +- __pycache__/retrieveOrder.cpython-39.pyc | Bin 1370 -> 1287 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI1.py b/GUI1.py index b48394b..d40c99f 100644 --- a/GUI1.py +++ b/GUI1.py @@ -35,7 +35,7 @@ def search(): #dropdown search by values -possibleSearches = ['order_id', 'order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] +possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number'] labelSearchBy = Label(main, text='Search by: ') labelSearchVal = Label(main, text='Search val:') diff --git a/__pycache__/retrieveOrder.cpython-39.pyc b/__pycache__/retrieveOrder.cpython-39.pyc index a3bb8318e421bc09aca5b21845f5920497f9a535..dcb72a0916bd1637e2865424aed77bbdcabcf53a 100644 GIT binary patch delta 311 zcmcb`)y~D2$ji&c00g_OHl`lroX97`m@!d1oh^kim_d_!;-QN?9*hhOB@8YM6BuJH zCeLToV#;Qke45d^eohV30_GIfg^ab#HH-_`7BbW@1Nm$V!R#`IqFE&@3s`HI7BVt2 z6tdJXq_Af*6S2fLIftf)Gn;7wV-X8BT?#3j3mMCRt}3!a)5HbV zWHEUrlPsg%=Iu;ebMeIN#ip{CCC_S}k@)DLA a5+XnW4xmDyRwgc14n_`U4rUf64s`%}+eY;O delta 326 zcmZqYy2Ztp$ji&c00iY`8&eIqCi2NJPMWBlZjj28%ALZU!qd#u%*e<9=JBTRA@TTA z1R%T=#$X0b!HF|2^4KskFqAO3Fic>K)tOw%sKr#qFnJ-PHRFuQcNrxl${32Km9Q*e ztzlXSG_jDSh9QMLo2lr;WI-mdjg3Dke{0 z;$Sq|Jd>%9F5KdbNlhNL2AUl@_I^7AZJo7MB#| z7qJ4xUUGnBK|~e1lb?}-sjJ&9_LR)xjQGryC{{ybLnGtK;Vd&4r6zx15o1^5V+26} DEeuHv From a904d2875f461f475356ef2cc0acb1a9cba657fc Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:39:38 +0000 Subject: [PATCH 33/34] Maybe fixed GUI Ad-hoc fix for the gui adding data to the table --- GUI1.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/GUI1.py b/GUI1.py index d40c99f..b85de93 100644 --- a/GUI1.py +++ b/GUI1.py @@ -14,23 +14,18 @@ def callback(selection): searchBy = selection def search(): - searchVal=entrySearchVal.get() - output = retrieve.retrieveOrder(currentSearchBy.get(), searchVal) #searchParameter, Value) - # print(currentSearchBy.get()) - print(output) - labelOutput.config(text=output) - - # for order in output: - # if output[0] == False: - # labelOutput.config(text="ERROR in input") - # else: - # labelOutput.config(text=output) - # for key, value in output.items(): - # print(key) - # print(value) - - food_delivery.insert(parent='',index='end',iid=0,text='', - values=('1','05-01-2023','101','Burger Bisto', '61340', 'BN2 9US', '16675', 'Classic Cheeseburger', '7.99', '92493', 'Sweet Potato Fries', '3.99', '11,98', 'BN2 5EF', '072442766728', '05-01-2023T19:45:00', '12')) + searchVal=entrySearchVal.get() + output = retrieve.retrieveOrder(currentSearchBy.get(), searchVal) #searchParameter, Value) + # print(currentSearchBy.get()) + print(output) + labelOutput.config(text=output) + + if output[0] == False: + labelOutput.config(text=output[1]) + else: + for order in output[1]: + food_delivery.insert(parent='',index='end',iid=0,text='', + values=('1',order.get('date'),'101','Burger Bisto', '61340', 'BN2 9US', '16675', 'Classic Cheeseburger', '7.99', '92493', 'Sweet Potato Fries', '3.99', '11,98', 'BN2 5EF', '072442766728', '05-01-2023T19:45:00', '12')) From 796251cc5ec1ad49e9b435f90b146cbc13259090 Mon Sep 17 00:00:00 2001 From: gjfrancis9 <67798013+gjfranics9@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:43:29 +0000 Subject: [PATCH 34/34] not sure why order.get always retrieves id of 1 Need to look into retrieving the correct ID --- GUI1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI1.py b/GUI1.py index b85de93..1e1c299 100644 --- a/GUI1.py +++ b/GUI1.py @@ -25,7 +25,7 @@ def search(): else: for order in output[1]: food_delivery.insert(parent='',index='end',iid=0,text='', - values=('1',order.get('date'),'101','Burger Bisto', '61340', 'BN2 9US', '16675', 'Classic Cheeseburger', '7.99', '92493', 'Sweet Potato Fries', '3.99', '11,98', 'BN2 5EF', '072442766728', '05-01-2023T19:45:00', '12')) + values=(order.get('order_id'),order.get('date'),'101','Burger Bisto', '61340', 'BN2 9US', '16675', 'Classic Cheeseburger', '7.99', '92493', 'Sweet Potato Fries', '3.99', '11,98', 'BN2 5EF', '072442766728', '05-01-2023T19:45:00', '12'))