Skip to content

Commit

Permalink
finish database is up
Browse files Browse the repository at this point in the history
  • Loading branch information
maggi373 committed Sep 5, 2024
1 parent 0f64daf commit 3093ee4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if not api_only:
if migratetechnic is True or new_user is True or DB_IS_UP != 1:
app.register_blueprint(asetup)
if DB_IS_UP == 1:
if DB_IS_UP != 2:
# Note that asite must be after setup
app.register_blueprint(alogin)
app.register_blueprint(asite)
Expand Down
12 changes: 7 additions & 5 deletions asetup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask import Blueprint, flash, redirect, render_template, request, url_for

from models.database import Database
from models.session import Session
from models.user import User
from models.common import migratetechnic, new_user, DB_IS_UP

Expand All @@ -15,15 +16,16 @@ def setup():
if Database.is_setup() == 2:
flash("An error occurred whilst trying to check database connection", "error")
return render_template("setup.html")
if Database.is_setup() == 0:
if DB_IS_UP == 0:
Database.create_tables()
if new_user == True or User.any_user_exists() == True:
Session.start_session_loop()
if new_user == True or User.any_user_exists() == False:
if migratetechnic:
Database.migratetechnic_tables()
return render_template("setup.html")
return render_template("setup.html")
else:
return redirect(url_for('asite.index'))
return redirect(url_for('app.login'))


@asetup.route("/setup", methods=["POST"])
Expand All @@ -40,6 +42,6 @@ def setup_creation():
return render_template("setup.html")
User.new(request.form["setupemail"], request.form["setupemail"],
request.form["setuppassword"], request.remote_addr, '1')
flash("Database created and user added", "success")
return redirect(url_for('asite.index'))
flash("user added", "success")
return redirect(url_for('alogin.login'))
return render_template("setup.html")

0 comments on commit 3093ee4

Please sign in to comment.