|
|
@@ -5,8 +5,8 @@ from .models import User, Art, List
|
|
|
from . import db
|
|
|
|
|
|
from . import dispatch
|
|
|
-from app.lib import clean_file as cf
|
|
|
-from app.lib import tools
|
|
|
+from app.lib import clean_file as cf, tools
|
|
|
+from app.lib import collector
|
|
|
|
|
|
from .forms import UPForm, PicForm, CAForm
|
|
|
|
|
|
@@ -15,14 +15,14 @@ dashboards = Blueprint('dashboards', __name__)
|
|
|
# Main Pages
|
|
|
@dashboards.route('/', methods=['GET', 'POST'])
|
|
|
def market():
|
|
|
- listings = List.query.all()
|
|
|
- art = Art.query.all()
|
|
|
- return_list = list()
|
|
|
- for l in listings:
|
|
|
- for a in art:
|
|
|
- if l.filehash == a.filehash:
|
|
|
- return_list.append([a.name, a.description, a.owner, a.creator, a.dname, l.seller, l.min_price, l.out_price, l.timeout, l.list_date])
|
|
|
-
|
|
|
+ return_list = collector.market_listing()
|
|
|
+
|
|
|
+ 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'))
|
|
|
|
|
|
return render_template('market.html', user=current_user, listings = return_list)
|
|
|
|
|
|
@@ -32,6 +32,13 @@ def profile():
|
|
|
form = UPForm()
|
|
|
form2 = PicForm()
|
|
|
|
|
|
+ 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 form2.validate_on_submit():
|
|
|
print('passsing')
|
|
|
f = form2.upload.data
|
|
|
@@ -40,8 +47,6 @@ def profile():
|
|
|
f.save(f'{cf.PROFILEPIC_FOLDER}/{designated_fn}')
|
|
|
dispatch.save_pp(designated_fn)
|
|
|
flash('Updated Profile Picture!', category='success')
|
|
|
- else:
|
|
|
- print('you dick')
|
|
|
|
|
|
|
|
|
if form.validate_on_submit():
|
|
|
@@ -76,15 +81,7 @@ def profile():
|
|
|
def create():
|
|
|
form = CAForm()
|
|
|
|
|
|
- owned_art = Art.query.filter_by(owner=current_user.id).all()
|
|
|
- listed_art = List.query.filter_by(seller=current_user.id).all()
|
|
|
- available_art = list()
|
|
|
-
|
|
|
- # to remove art that is already listed
|
|
|
- for oa in owned_art:
|
|
|
- for la in listed_art:
|
|
|
- if oa.filehash != la.filehash:
|
|
|
- available_art.append(oa)
|
|
|
+ available_art = collector.check_listing()
|
|
|
|
|
|
# check POST req
|
|
|
if form.validate_on_submit():
|
|
|
@@ -101,16 +98,29 @@ def create():
|
|
|
designated_fn = cf.sanitize(new_art.filename)
|
|
|
new_art.save(f'{cf.UPLOAD_FOLDER}/{designated_fn}')
|
|
|
dispatch.mint(designated_fn, art_name, art_desc, min_price, buyout_price, close_date)
|
|
|
- # elif here
|
|
|
+ flash('Minted & Listed!', category='success')
|
|
|
|
|
|
return render_template('create_art.html', user = current_user, form = form, av_art = available_art)
|
|
|
|
|
|
@dashboards.route('/search')
|
|
|
@login_required
|
|
|
def search():
|
|
|
- return render_template('search.html', user=current_user)
|
|
|
+ return render_template('search.html', user = current_user)
|
|
|
|
|
|
@dashboards.route('/detail')
|
|
|
@login_required
|
|
|
def detail():
|
|
|
- return render_template('detail_art.html', user=current_user)
|
|
|
+
|
|
|
+ focus = None
|
|
|
+
|
|
|
+ # Collects details of the listing based on the
|
|
|
+ # focus pointer of the user
|
|
|
+ return_list = collector.market_listing()
|
|
|
+ for item in return_list:
|
|
|
+ if item[11] == current_user.focus: # comparing hash
|
|
|
+ focus = item
|
|
|
+ break
|
|
|
+
|
|
|
+ owner_obj = collector.find_user_obj(focus[2])
|
|
|
+
|
|
|
+ return render_template('detail_art.html', user = current_user, detail = focus, own_uname = owner_obj.username)
|