Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cooler branch #3

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
426aa79
Summary
gjfranics9 Jan 24, 2024
9210400
summary
jamiesage Jan 24, 2024
ba6931c
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
jamiesage Jan 24, 2024
b44010b
add command to button
jamiesage Jan 24, 2024
fadc2c0
Update for overlapping data
gjfranics9 Jan 24, 2024
b54810e
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
gjfranics9 Jan 24, 2024
73d987d
Normalisation
gjfranics9 Jan 24, 2024
b949231
Update GUI1.py
jamiesage Jan 24, 2024
d4bb09d
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
jamiesage Jan 24, 2024
bd1d83e
Sanitisation
gjfranics9 Jan 24, 2024
f71c8cf
Reformatted, added contact number, fixed adding to searched_orders list
gjfranics9 Jan 24, 2024
586e119
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
gjfranics9 Jan 24, 2024
7e138ca
Update GUI1.py
jamiesage Jan 24, 2024
736c7ac
Update retrieveOrder.py
gjfranics9 Jan 24, 2024
202e5d2
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
gjfranics9 Jan 24, 2024
0274b8f
house number added
Jeevan2191999 Jan 24, 2024
f0d9dac
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
Jeevan2191999 Jan 24, 2024
f831ec6
Update GUI1.py
Intissar-elyaalaoui Jan 24, 2024
30b1f57
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
Intissar-elyaalaoui Jan 24, 2024
d0fe421
added house number
Jeevan2191999 Jan 24, 2024
70b4d6c
bugfix
gjfranics9 Jan 24, 2024
f2a2523
Comments
gjfranics9 Jan 24, 2024
1ae12b7
new change
jamiesage Jan 24, 2024
b4af9bd
Update GUI1.py
gjfranics9 Jan 24, 2024
9df0e91
made an update with dish id
Jeevan2191999 Jan 24, 2024
e7253d7
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
gjfranics9 Jan 24, 2024
4ab2702
updated with the dish id
Jeevan2191999 Jan 24, 2024
c7a6c0b
Cast help
gjfranics9 Jan 24, 2024
a63af7a
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
gjfranics9 Jan 24, 2024
f345d8b
Update retrieveOrder.py
gjfranics9 Jan 24, 2024
1ea1aac
new
jamiesage Jan 24, 2024
74a82c6
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
jamiesage Jan 24, 2024
875a015
Removed dishID
gjfranics9 Jan 24, 2024
c1c1eb3
Update retrieveOrder.cpython-39.pyc
gjfranics9 Jan 24, 2024
f58062f
s
jamiesage Jan 24, 2024
52ac8ed
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
jamiesage Jan 24, 2024
e18a150
latest
jamiesage Jan 24, 2024
f6144ea
Fixed excessive adding to dicitonary
gjfranics9 Jan 24, 2024
3e21d90
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
gjfranics9 Jan 24, 2024
5aa4913
Removed test
gjfranics9 Jan 24, 2024
7bf67bb
Fixed the one sided capital letter normalisation
gjfranics9 Jan 24, 2024
38bc3ce
new
jamiesage Jan 24, 2024
3c20cef
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
jamiesage Jan 24, 2024
8f40b8e
Update retrieveOrder.cpython-311.pyc
Intissar-elyaalaoui Jan 24, 2024
56f9b3a
latestnew
jamiesage Jan 24, 2024
c009949
Merge branch 'coolerBranch' of https://github.com/Inshur/tech-insight…
jamiesage Jan 24, 2024
a9d318f
1
gjfranics9 Jan 24, 2024
a904d28
Maybe fixed GUI
gjfranics9 Jan 25, 2024
796251c
not sure why order.get always retrieves id of 1
gjfranics9 Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
91 changes: 91 additions & 0 deletions GUI1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from tkinter import *
from tkinter.ttk import *

import retrieveOrder as retrieve

main = Tk()
# main.geometry('1000x1000')
width, height = main.winfo_screenwidth(), main.winfo_screenheight()

main.geometry('%dx%d+0+0' % (width,height))

searchBy = 'order_id'
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)

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=(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'))



#dropdown search by values
possibleSearches = ['order_id', 'date', 'restaurant', 'postcode', 'contact_number', 'house_number']

labelSearchBy = Label(main, text='Search by: ')
labelSearchVal = Label(main, text='Search val:')

currentSearchBy = StringVar()
currentSearchBy.set('order_id')

dropSearchBy = OptionMenu(main, currentSearchBy, *possibleSearches, command=callback)
entrySearchVal = Entry(main)

buttonSearch = Button(main, text='Search', command=search)

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)
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')

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.grid(row= 5, column= 0, rowspan=3)
main.mainloop()

Binary file added __pycache__/retrieveOrder.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/retrieveOrder.cpython-39.pyc
Binary file not shown.
59 changes: 59 additions & 0 deletions retrieveOrder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import json
from multiprocessing.sharedctypes import Value
from re import search
import requests

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']

#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 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
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':
if str(Value) in order.get(searchParameter):
searched_orders.append(order)
elif searchParameter == 'restaurant':
restaurant = order.get('restaurant')
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').lower():
searched_orders.append(order)
elif searchParameter == 'contact_number':
address = order.get('delivery')
if Value.lower() in address.get('contact_number'):
searched_orders.append(order)
elif searchParameter == 'house_number':
address = order.get('delivery')
if Value.lower() in address.get('house_number'):
searched_orders.append('delivery')
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'))