diff --git a/goathacks/dashboard/__init__.py b/goathacks/dashboard/__init__.py index c6d4699..c6dc7fb 100644 --- a/goathacks/dashboard/__init__.py +++ b/goathacks/dashboard/__init__.py @@ -1,4 +1,4 @@ -from flask import Blueprint, current_app, flash, jsonify, render_template, request +from flask import Blueprint, current_app, flash, jsonify, redirect, render_template, request, url_for from flask_login import current_user, login_required from werkzeug.utils import secure_filename @@ -47,9 +47,17 @@ def resume(): filename = current_user.first_name.lower() + '_' + current_user.last_name.lower() + '_' + str( current_user.id) + '.' + resume.filename.split('.')[-1].lower() filename = secure_filename(filename) + if not os.path.exists(current_app.config['UPLOAD_FOLDER']): + try: + os.makedirs(current_app.config['UPLOAD_FOLDER']) + except Exception: + flash("Error saving resume. Contact acm-sysadmin@wpi.edu") + return redirect(url_for("dashboard.home")) resume.save(os.path.join(current_app.config['UPLOAD_FOLDER'], filename)) - return 'Resume uploaded! Return to dashboard' - return "Something went wrong. If this keeps happening, contact hack@wpi.edu for assistance" + flash("Resume uploaded!") + return redirect(url_for("dashboard.home")) + flash("Something went wrong. If this keeps happening, contact hack@wpi.edu for assistance") + return redirect(url_for("dashboard.home")) def allowed_file(filename): diff --git a/goathacks/templates/dashboard.html b/goathacks/templates/dashboard.html index 649ec80..7813b56 100644 --- a/goathacks/templates/dashboard.html +++ b/goathacks/templates/dashboard.html @@ -33,7 +33,7 @@