|
|
@@ -1,10 +1,12 @@
|
|
|
from flask import Blueprint, render_template, request, flash, redirect, url_for
|
|
|
from flask_login import login_required, current_user
|
|
|
+from werkzeug.security import generate_password_hash, check_password_hash
|
|
|
from .models import User
|
|
|
from . import db
|
|
|
|
|
|
dashboards = Blueprint('dashboards', __name__)
|
|
|
|
|
|
+# Main Pages
|
|
|
@dashboards.route('/', methods=['GET', 'POST'])
|
|
|
def market():
|
|
|
return render_template('market.html', user=current_user)
|
|
|
@@ -12,8 +14,30 @@ def market():
|
|
|
@dashboards.route('/profile', methods=['GET', 'POST'])
|
|
|
@login_required
|
|
|
def profile():
|
|
|
- return render_template('profile.html', user=current_user)
|
|
|
+ # fetch post request
|
|
|
+ if request.method == "POST":
|
|
|
+ cpasswd = request.form.get('current_password')
|
|
|
+ passwd = request.form.get('password')
|
|
|
+ passwd_con = request.form.get('password_confirm')
|
|
|
+
|
|
|
+ # password check before update
|
|
|
+ if passwd and passwd_con and cpasswd:
|
|
|
+ if passwd == passwd_con and check_password_hash(current_user.password, cpasswd):
|
|
|
+ npasswd_dbcall = User.query.filter_by(id=current_user.id).first()
|
|
|
+ npasswd_dbcall.password = generate_password_hash(passwd_con, method='sha256')
|
|
|
+ db.session.commit()
|
|
|
+ flash('Updated password!', category='success')
|
|
|
+ else:
|
|
|
+ flash('Password update failed!', category='error')
|
|
|
+
|
|
|
+ return render_template('profile.html', user=current_user)
|
|
|
+
|
|
|
+@dashboards.route('/create_art', methods=['GET', 'POST'])
|
|
|
+#login_required
|
|
|
+def create():
|
|
|
+ return render_template('create_art.html', user=current_user)
|
|
|
|
|
|
+# Pop Ups
|
|
|
@dashboards.route('/modal_home')
|
|
|
def modal_home():
|
|
|
return render_template('detail_art_for_home.html', user=current_user)
|