Add option to download menus, make DB creation easier

This commit is contained in:
redfast00 2020-12-04 20:21:12 +01:00
parent ec7c8ed40b
commit fad23fbeda
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C
2 changed files with 15 additions and 9 deletions

View file

@ -31,14 +31,10 @@ def add_all() -> None:
def recreate_from_scratch() -> None: def recreate_from_scratch() -> None:
"Recreate a completely new database" "Recreate a completely new database"
confirmation = "Are you very very sure? (Will delete previous entries!) (y/N) " print("Resetting the database!")
if input(confirmation).lower() in yes: db.drop_all()
print("Resetting the database!") db.create_all()
db.drop_all() add_to_current()
db.create_all()
add_to_current()
else:
print("You cancelled.")
def add_to_current() -> None: def add_to_current() -> None:
@ -75,7 +71,7 @@ def setup_database(): # type: None
"Start the database interaction script" "Start the database interaction script"
print("Database modification script!") print("Database modification script!")
print("=============================\n\n") print("=============================\n\n")
if check_if_overwrite(): if (not db.engine.table_names()) or check_if_overwrite():
recreate_from_scratch() recreate_from_scratch()
else: else:
add_to_current() add_to_current()

View file

@ -40,4 +40,14 @@ fi
echo -e "${B} Seeding database ${E}" echo -e "${B} Seeding database ${E}"
./populate-db.sh ./populate-db.sh
if [ ! -d "menus" ]; then
echo -en "${B} Do you want to use the Zeus HLDS menus? If not, you will have to clone your own menu repository. (Y/n) ${E}"
read confirm
if [ "$confirm" = n ]; then
echo "Not cloning the Zeus HLDS menus"
else
git clone https://git.zeus.gent/haldis/menus.git
fi
fi
echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the development server with 'python app/app.py runserver' ${E}" echo -e "${B} Activate your venv using 'source venv/bin/activate'.\nThen run the development server with 'python app/app.py runserver' ${E}"