Fix url_for crash on "home_page"

This commit is contained in:
rubenwardy 2019-11-21 19:38:26 +00:00
parent b977a42738
commit 39d4cf362b
6 changed files with 12 additions and 9 deletions

3
.dockerignore Normal file

@ -0,0 +1,3 @@
.git
data
uploads

@ -8,7 +8,7 @@ from sqlalchemy.sql.expression import func
@bp.route("/") @bp.route("/")
@menu.register_menu(bp, ".", "Home") @menu.register_menu(bp, ".", "Home")
def home_page(): def home():
query = Package.query.filter_by(approved=True, soft_deleted=False) query = Package.query.filter_by(approved=True, soft_deleted=False)
count = query.count() count = query.count()
new = query.order_by(db.desc(Package.created_at)).limit(8).all() new = query.order_by(db.desc(Package.created_at)).limit(8).all()

@ -87,7 +87,7 @@ def view(id):
if package: if package:
return redirect(package.getDetailsURL()) return redirect(package.getDetailsURL())
else: else:
return redirect(url_for("home_page")) return redirect(url_for("homepage.home"))
if len(comment) <= 500 and len(comment) > 3: if len(comment) <= 500 and len(comment) > 3:
reply = ThreadReply() reply = ThreadReply()
@ -150,7 +150,7 @@ def new():
# Check that user can make the thread # Check that user can make the thread
if not package.checkPerm(current_user, Permission.CREATE_THREAD): if not package.checkPerm(current_user, Permission.CREATE_THREAD):
flash("Unable to create thread!", "error") flash("Unable to create thread!", "error")
return redirect(url_for("home_page")) return redirect(url_for("homepage.home"))
# Only allow creating one thread when not approved # Only allow creating one thread when not approved
elif is_review_thread and package.review_thread is not None: elif is_review_thread and package.review_thread is not None:
@ -163,7 +163,7 @@ def new():
if package: if package:
return redirect(package.getDetailsURL()) return redirect(package.getDetailsURL())
else: else:
return redirect(url_for("home_page")) return redirect(url_for("homepage.home"))
# Set default values # Set default values
elif request.method == "GET": elif request.method == "GET":

@ -54,10 +54,10 @@ def github_authorized(oauth_token):
current_user.github_username = username current_user.github_username = username
db.session.commit() db.session.commit()
flash("Linked github to account", "success") flash("Linked github to account", "success")
return redirect(url_for("home_page")) return redirect(url_for("homepage.home"))
else: else:
flash("Github account is already associated with another user", "danger") flash("Github account is already associated with another user", "danger")
return redirect(url_for("home_page")) return redirect(url_for("homepage.home"))
# If not logged in, log in # If not logged in, log in
else: else:
@ -68,7 +68,7 @@ def github_authorized(oauth_token):
if current_user.password is None: if current_user.password is None:
return redirect(next_url or url_for("users.set_password", optional=True)) return redirect(next_url or url_for("users.set_password", optional=True))
else: else:
return redirect(next_url or url_for("home_page")) return redirect(next_url or url_for("homepage.home"))
else: else:
flash("Authorization failed [err=gh-login-failed]", "danger") flash("Authorization failed [err=gh-login-failed]", "danger")
return redirect(url_for("user.login")) return redirect(url_for("user.login"))

@ -306,4 +306,4 @@ def verify_email():
if current_user.is_authenticated: if current_user.is_authenticated:
return redirect(url_for("users.profile", username=current_user.username)) return redirect(url_for("users.profile", username=current_user.username))
else: else:
return redirect(url_for("home_page")) return redirect(url_for("homepage.home"))

@ -10,7 +10,7 @@
<div class="alert alert-primary"> <div class="alert alert-primary">
It is recommended that you set a password for your account. It is recommended that you set a password for your account.
<a class="alert_right button" href="{{ url_for('home_page') }}">Skip</a> <a class="alert_right button" href="{{ url_for('homepage.home') }}">Skip</a>
</div> </div>
{% endif %} {% endif %}