|
|
@@ -19,10 +19,11 @@ def market():
|
|
|
|
|
|
if request.method == "POST":
|
|
|
focus_item = request.form.get('focus_but')
|
|
|
- u_dbcall = User.query.filter_by(id=current_user.id).first()
|
|
|
- u_dbcall.focus = focus_item
|
|
|
- db.session.commit()
|
|
|
- return redirect(url_for('dashboards.detail'))
|
|
|
+ if focus_item and current_user.is_authenticated:
|
|
|
+ u_dbcall = User.query.filter_by(id=current_user.id).first()
|
|
|
+ u_dbcall.focus = focus_item
|
|
|
+ db.session.commit()
|
|
|
+ return redirect(url_for('dashboards.detail'))
|
|
|
|
|
|
return render_template('market.html', user=current_user, listings = return_list)
|
|
|
|
|
|
@@ -33,6 +34,8 @@ def profile():
|
|
|
form2 = PicForm()
|
|
|
user_bid_hist = collector.user_bid_hist(current_user.id)
|
|
|
|
|
|
+ # This takes a post request button press
|
|
|
+ # when user clicks on a photo
|
|
|
if request.method == "POST":
|
|
|
focus_item = request.form.get('focus_but')
|
|
|
if focus_item and collector.check_art_listing(focus_item):
|
|
|
@@ -40,10 +43,12 @@ def profile():
|
|
|
u_dbcall.focus = focus_item
|
|
|
db.session.commit()
|
|
|
return redirect(url_for('dashboards.detail'))
|
|
|
- elif focus_item and collector.check_art_listing(focus_item):
|
|
|
- pass
|
|
|
+ elif focus_item and not collector.check_art_listing(focus_item):
|
|
|
+ # else if there's a click but no listing, don't do anything
|
|
|
+ flash('Auction page not available to items not for sale!', category='error')
|
|
|
|
|
|
|
|
|
+ # Profile Picture Update Form
|
|
|
if form2.validate_on_submit():
|
|
|
print('passsing')
|
|
|
f = form2.upload.data
|
|
|
@@ -54,12 +59,13 @@ def profile():
|
|
|
flash('Updated Profile Picture!', category='success')
|
|
|
|
|
|
|
|
|
+ # Password Update Form
|
|
|
if form.validate_on_submit():
|
|
|
cpasswd = form.cpasswd.data
|
|
|
passwd = form.passwd_1.data
|
|
|
passwd_con = form.passwd_2.data
|
|
|
|
|
|
- # password check before update
|
|
|
+ # Basic password checks before adding to db
|
|
|
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()
|