Fix pylint for database files

This commit is contained in:
Jan-Pieter Baert 2019-09-09 23:19:21 +02:00
parent bbbec95b92
commit d21f2d48f5
No known key found for this signature in database
GPG key ID: B19186932178234A
7 changed files with 37 additions and 18 deletions

View file

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

View file

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

View file

@ -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",

View file

@ -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)",

View file

@ -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",

View file

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

View file

@ -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():