diff --git a/app/database/add_admins.py b/app/database/add_admins.py index cb385c7..f47dfe0 100644 --- a/app/database/add_admins.py +++ b/app/database/add_admins.py @@ -1,8 +1,10 @@ +"Script for adding users as admin to Haldis." from app import db from models import User def add() -> None: + "Add users as admin." feli = User() feli.configure("feliciaan", True, 0) db.session.add(feli) diff --git a/app/database/add_fitchen.py b/app/database/add_fitchen.py index b9a885e..ff55132 100644 --- a/app/database/add_fitchen.py +++ b/app/database/add_fitchen.py @@ -1,3 +1,4 @@ +"Script to add Fitchen to Haldis" from app import db from models import Location, Product @@ -23,14 +24,15 @@ pricedict = {"Small": 799, "Medium": 999, "Large": 1199} def add() -> None: - simpizza = Location() - simpizza.configure("Fitchen", "?", "?", "https://www.fitchen.be/") - db.session.add(simpizza) + "Add Fitchen to the database" + fitchen = Location() + fitchen.configure("Fitchen", "?", "?", "https://www.fitchen.be/") + db.session.add(fitchen) for menuitem in menuitems: for size, price in pricedict.items(): for container in ["bowl", "wrap"]: name = "%s %s in %s" % (size, menuitem, container) entry = Product() - entry.configure(simpizza, name, price) + entry.configure(fitchen, name, price) db.session.add(entry) diff --git a/app/database/add_oceans_garden.py b/app/database/add_oceans_garden.py index fb293ef..a89fda8 100644 --- a/app/database/add_oceans_garden.py +++ b/app/database/add_oceans_garden.py @@ -1,3 +1,4 @@ +"Script to add Ocean Garden to Haldis" from itertools import product from app import db @@ -30,6 +31,7 @@ specials = [ def add() -> None: + "Add Ocean Garden to the database" chinees = Location() chinees.configure( "Oceans's Garden", diff --git a/app/database/add_primadonna.py b/app/database/add_primadonna.py index 5bbb3c4..b940652 100644 --- a/app/database/add_primadonna.py +++ b/app/database/add_primadonna.py @@ -1,8 +1,10 @@ +"Script to add Primadonna to Haldis" from app import db from models import Location, Product def add(): + "Add Primadonna to the database" addTA() addAfhalen() @@ -47,6 +49,7 @@ pizzasTA = { def addTA() -> None: + "Add Primadonna on takeaway.com to the database" primadonna_takeaway = Location() primadonna_takeaway.configure( "Primadonna (takeaway laten bezorgen)", @@ -102,6 +105,7 @@ pizzasAfhalen = { def addAfhalen() -> None: + "Add Primadonna to takeaway to the database" primadonna_afhalen = Location() primadonna_afhalen.configure( "Primadonna (bellen en afhalen)", diff --git a/app/database/add_simpizza.py b/app/database/add_simpizza.py index 77a6c0f..1a3e938 100644 --- a/app/database/add_simpizza.py +++ b/app/database/add_simpizza.py @@ -1,3 +1,4 @@ +"Script to add SimPizza to Haldis" from app import db from models import Location, Product @@ -19,7 +20,8 @@ pizzas = [ "Chicken bbq", "Funky chicken", "Veggie", - "Meat lovers" "Scampi mampi", + "Meat lovers", + "Scampi mampi", "Tabasco", "Chicken time", "Meatballs", @@ -33,6 +35,7 @@ pizzas = [ def add() -> None: + "Add Simpizza to the database" simpizza = Location() simpizza.configure( "Sim-pizza", diff --git a/app/database/add_stefanos.py b/app/database/add_stefanos.py index 9868d29..8cb0fc5 100644 --- a/app/database/add_stefanos.py +++ b/app/database/add_stefanos.py @@ -1,3 +1,4 @@ +"Script to add Stefanos to Haldis" from app import db from models import Location, Product @@ -101,12 +102,13 @@ data = [special_bickies, specials, vlezekes, friet] def add() -> None: + "Add Stefanos to the database" stefanos = Location() stefanos.configure( "Stefano's Place", "Overpoortstraat 12 9000 Gent", "tel: geen", - "https://www.facebook.com/pages/category/Fast-Food-Restaurant/Stefanos-Place-370774480004139/", + "https://www.facebook.com/pages/category/Fast-Food-Restaurant/Stefanos-Place-370774480004139/", # pylint: disable=C0301 ) db.session.add(stefanos) @@ -120,8 +122,8 @@ def add() -> None: bicky_cheese.configure(stefanos, name + " cheese", price + 30) db.session.add(bicky_cheese) - for dict in data: - for name, price in dict.items(): + for dictionary in data: + for name, price in dictionary.items(): item = Product() item.configure(stefanos, name, price) db.session.add(item) diff --git a/app/database/create_database.py b/app/database/create_database.py index 3af6957..128af81 100644 --- a/app/database/create_database.py +++ b/app/database/create_database.py @@ -1,3 +1,4 @@ +"Script for interaction and changes to the database" import add_admins import add_fitchen import add_oceans_garden @@ -17,27 +18,30 @@ yes = ["yes", "y", "Y"] no = ["no", "n", "N"] -# Commit all the things def commit() -> None: + "Commit all the things to the database" db.session.commit() print("Committing successful") def check_if_overwrite() -> bool: + "Check if the user wants to overwrite the previous database" answer = input("Do you want to overwrite the previous database? (y/N) ") return answer in yes def add_all() -> None: - for entry_set in entry_sets.keys(): + "Add all possible entries in the entry_sets to the database" + for entry_set, function in entry_sets.items(): print("Adding {}.".format(entry_set)) - entry_sets[entry_set]() + function() def recreate_from_scratch() -> None: - confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) " + "Recreate a completely new database" + confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) " # pylint: disable=C0301 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: # pylint: disable=C0301 print("Resetting the database!") db.drop_all() db.create_all() @@ -45,6 +49,7 @@ def recreate_from_scratch() -> None: def add_to_current() -> None: + "Add things to the current database" available = [entry_set for entry_set in entry_sets] def add_numbers() -> str: @@ -53,16 +58,14 @@ def add_to_current() -> None: ).rstrip(", ") while input("Do you still want to add something? (Y/n) ") not in no: - print( - "What do you want to add? (Use numbers, or A for all, or C for cancel) " - ) + print("What do you want to add? (Use numbers, or A for all, or C for cancel) ") # pylint: disable=C0301 answer = input("Available: {} : ".format(add_numbers())) if answer == "A": add_all() available = [] elif answer == "C": pass - elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]: + elif answer.isnumeric() and answer in [str(x) for x in range(len(available))]: # pylint: disable=C0301 answer_index = int(answer) print("Adding {}.".format(available[answer_index])) entry_sets[str(available[answer_index])]() @@ -74,7 +77,8 @@ def add_to_current() -> None: manager = create_app() @manager.command -def setup_database(): +def setup_database(): #type: None + "Start the database interaction script" print("Database modification script!") print("=============================\n\n") if check_if_overwrite():