Add typing to database files
This commit is contained in:
parent
9459eb0f1e
commit
51edd1bdc1
7 changed files with 23 additions and 23 deletions
|
@ -2,7 +2,7 @@ from app import db
|
||||||
from models import User
|
from models import User
|
||||||
|
|
||||||
|
|
||||||
def add():
|
def add() -> None:
|
||||||
feli = User()
|
feli = User()
|
||||||
feli.configure("feliciaan", True, 0)
|
feli.configure("feliciaan", True, 0)
|
||||||
db.session.add(feli)
|
db.session.add(feli)
|
||||||
|
|
|
@ -23,7 +23,7 @@ menuitems = [
|
||||||
pricedict = {"Small": 799, "Medium": 999, "Large": 1199}
|
pricedict = {"Small": 799, "Medium": 999, "Large": 1199}
|
||||||
|
|
||||||
|
|
||||||
def add():
|
def add() -> None:
|
||||||
simpizza = Location()
|
simpizza = Location()
|
||||||
simpizza.configure("Fitchen", "?", "?", "https://www.fitchen.be/")
|
simpizza.configure("Fitchen", "?", "?", "https://www.fitchen.be/")
|
||||||
db.session.add(simpizza)
|
db.session.add(simpizza)
|
||||||
|
|
|
@ -29,7 +29,7 @@ specials = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def add():
|
def add() -> None:
|
||||||
chinees = Location()
|
chinees = Location()
|
||||||
chinees.configure(
|
chinees.configure(
|
||||||
"Oceans's Garden",
|
"Oceans's Garden",
|
||||||
|
@ -39,12 +39,12 @@ def add():
|
||||||
)
|
)
|
||||||
db.session.add(chinees)
|
db.session.add(chinees)
|
||||||
|
|
||||||
def chinees_create_entry(name):
|
def chinees_create_entry(name) -> None:
|
||||||
entry = Product()
|
entry = Product()
|
||||||
entry.configure(chinees, name, 550)
|
entry.configure(chinees, name, 550)
|
||||||
db.session.add(entry)
|
db.session.add(entry)
|
||||||
|
|
||||||
def chinees_create_regulat(zetmeel, vlees="", saus=""):
|
def chinees_create_regulat(zetmeel, vlees="", saus="") -> None:
|
||||||
chinees_create_entry("{} {} {}".format(zetmeel, vlees, saus).rstrip())
|
chinees_create_entry("{} {} {}".format(zetmeel, vlees, saus).rstrip())
|
||||||
|
|
||||||
for z, v, s in product(zetmelen, vlezen, sauzen):
|
for z, v, s in product(zetmelen, vlezen, sauzen):
|
||||||
|
|
|
@ -46,7 +46,7 @@ pizzasTA = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def addTA():
|
def addTA() -> None:
|
||||||
primadonna_takeaway = Location()
|
primadonna_takeaway = Location()
|
||||||
primadonna_takeaway.configure(
|
primadonna_takeaway.configure(
|
||||||
"Primadonna (takeaway laten bezorgen)",
|
"Primadonna (takeaway laten bezorgen)",
|
||||||
|
@ -101,7 +101,7 @@ pizzasAfhalen = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def addAfhalen():
|
def addAfhalen() -> None:
|
||||||
primadonna_afhalen = Location()
|
primadonna_afhalen = Location()
|
||||||
primadonna_afhalen.configure(
|
primadonna_afhalen.configure(
|
||||||
"Primadonna (bellen en afhalen)",
|
"Primadonna (bellen en afhalen)",
|
||||||
|
|
|
@ -33,7 +33,7 @@ pizzas = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def add():
|
def add() -> None:
|
||||||
simpizza = Location()
|
simpizza = Location()
|
||||||
simpizza.configure(
|
simpizza.configure(
|
||||||
"Sim-pizza",
|
"Sim-pizza",
|
||||||
|
|
|
@ -11,7 +11,7 @@ bickies = {
|
||||||
"Bicky Veggie": 350,
|
"Bicky Veggie": 350,
|
||||||
}
|
}
|
||||||
|
|
||||||
saus = {
|
sauskes = {
|
||||||
"american": 70,
|
"american": 70,
|
||||||
"andalouse": 70,
|
"andalouse": 70,
|
||||||
"bicky saus": 70,
|
"bicky saus": 70,
|
||||||
|
@ -100,7 +100,7 @@ friet = {"Klein pak": 200, "Midden pak": 250, "Groot pak": 300}
|
||||||
data = [special_bickies, specials, vlezekes, friet]
|
data = [special_bickies, specials, vlezekes, friet]
|
||||||
|
|
||||||
|
|
||||||
def add():
|
def add() -> None:
|
||||||
stefanos = Location()
|
stefanos = Location()
|
||||||
stefanos.configure(
|
stefanos.configure(
|
||||||
"Stefano's Place",
|
"Stefano's Place",
|
||||||
|
@ -127,7 +127,7 @@ def add():
|
||||||
db.session.add(item)
|
db.session.add(item)
|
||||||
|
|
||||||
# saus in een potteke bestellen is 10 cent extra
|
# saus in een potteke bestellen is 10 cent extra
|
||||||
for name, price in saus.items():
|
for name, price in sauskes.items():
|
||||||
saus = Product()
|
saus = Product()
|
||||||
saus.configure(stefanos, name, price)
|
saus.configure(stefanos, name, price)
|
||||||
db.session.add(saus)
|
db.session.add(saus)
|
||||||
|
|
|
@ -15,23 +15,23 @@ no = ["no", "n", "N"]
|
||||||
|
|
||||||
|
|
||||||
# Commit all the things
|
# Commit all the things
|
||||||
def commit():
|
def commit() -> None:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
print("Committing successful")
|
print("Committing successful")
|
||||||
|
|
||||||
|
|
||||||
def check_if_overwrite():
|
def check_if_overwrite() -> bool:
|
||||||
answer = input("Do you want to overwrite the previous database? (y/N) ")
|
answer = input("Do you want to overwrite the previous database? (y/N) ")
|
||||||
return answer in yes
|
return answer in yes
|
||||||
|
|
||||||
|
|
||||||
def add_all():
|
def add_all() -> None:
|
||||||
for entry_set in entry_sets.keys():
|
for entry_set in entry_sets.keys():
|
||||||
print("Adding {}.".format(entry_set))
|
print("Adding {}.".format(entry_set))
|
||||||
entry_sets[entry_set]()
|
entry_sets[entry_set]()
|
||||||
|
|
||||||
|
|
||||||
def recreate_from_scratch():
|
def recreate_from_scratch() -> None:
|
||||||
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) "
|
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) "
|
||||||
check = "I acknowledge any repercussions!"
|
check = "I acknowledge any repercussions!"
|
||||||
if input(confirmation) in yes and input("Type: '{}' ".format(check)) == check:
|
if input(confirmation) in yes and input("Type: '{}' ".format(check)) == check:
|
||||||
|
@ -41,10 +41,10 @@ def recreate_from_scratch():
|
||||||
add_to_current()
|
add_to_current()
|
||||||
|
|
||||||
|
|
||||||
def add_to_current():
|
def add_to_current() -> None:
|
||||||
available = [entry_set for entry_set in entry_sets]
|
available = [entry_set for entry_set in entry_sets]
|
||||||
|
|
||||||
def add_numbers():
|
def add_numbers() -> str:
|
||||||
return " ".join(
|
return " ".join(
|
||||||
["{}({}), ".format(loc, i) for i, loc in enumerate(available)]
|
["{}({}), ".format(loc, i) for i, loc in enumerate(available)]
|
||||||
).rstrip(", ")
|
).rstrip(", ")
|
||||||
|
@ -59,17 +59,17 @@ def add_to_current():
|
||||||
available = []
|
available = []
|
||||||
elif answer == "C":
|
elif answer == "C":
|
||||||
pass
|
pass
|
||||||
elif answer in [str(x) for x in range(len(available))]:
|
elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]:
|
||||||
answer = int(answer)
|
answer_index = int(answer)
|
||||||
print("Adding {}.".format(available[answer]))
|
print("Adding {}.".format(available[answer_index]))
|
||||||
entry_sets[str(available[answer])]()
|
entry_sets[str(available[answer_index])]()
|
||||||
del available[answer]
|
del available[answer_index]
|
||||||
else:
|
else:
|
||||||
print("Not a valid answer.")
|
print("Not a valid answer.")
|
||||||
print("Thank you for adding, come again!")
|
print("Thank you for adding, come again!")
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init() -> None:
|
||||||
print("Database modification script!")
|
print("Database modification script!")
|
||||||
print("=============================\n\n")
|
print("=============================\n\n")
|
||||||
if check_if_overwrite():
|
if check_if_overwrite():
|
||||||
|
|
Loading…
Reference in a new issue