|
|
@@ -9,7 +9,7 @@ from app.lib import clean_file as cf, tools
|
|
|
from app.lib import collector
|
|
|
from app.lib import stripe
|
|
|
|
|
|
-from .forms import UPForm, PicForm, CAForm, BidForm, WalletForm
|
|
|
+from .forms import UPForm, PicForm, CAForm, BidForm, WalletForm, SearchForm
|
|
|
|
|
|
dashboards = Blueprint('dashboards', __name__)
|
|
|
|
|
|
@@ -18,6 +18,8 @@ dashboards = Blueprint('dashboards', __name__)
|
|
|
def market():
|
|
|
return_list = collector.join_art_list_table()
|
|
|
|
|
|
+ seform = SearchForm()
|
|
|
+
|
|
|
if request.method == "POST":
|
|
|
focus_item = request.form.get('focus_but')
|
|
|
if focus_item and current_user.is_authenticated:
|
|
|
@@ -26,7 +28,7 @@ def market():
|
|
|
db.session.commit()
|
|
|
return redirect(url_for('dashboards.detail'))
|
|
|
|
|
|
- return render_template('market.html', user=current_user, listings = return_list)
|
|
|
+ return render_template('market.html', user=current_user, listings = return_list, seform = seform)
|
|
|
|
|
|
@dashboards.route('/profile', methods=['GET', 'POST'])
|
|
|
@login_required
|
|
|
@@ -36,6 +38,8 @@ def profile():
|
|
|
form3 = WalletForm()
|
|
|
user_bid_hist = collector.user_bid_hist(current_user.id)
|
|
|
|
|
|
+ seform = SearchForm()
|
|
|
+
|
|
|
# Initializes wallet and fetches amount
|
|
|
dispatch.init_wallet(current_user.id)
|
|
|
wallet = Wallet.query.filter_by(user_id = current_user.id).first()
|
|
|
@@ -112,7 +116,8 @@ def profile():
|
|
|
form2 = form2,
|
|
|
form3 = form3,
|
|
|
ubh = user_bid_hist,
|
|
|
- wallet_amount = wallet_amount
|
|
|
+ wallet_amount = wallet_amount,
|
|
|
+ seform = seform
|
|
|
)
|
|
|
|
|
|
@dashboards.route('/create_art', methods=['GET', 'POST'])
|
|
|
@@ -122,6 +127,8 @@ def create():
|
|
|
|
|
|
available_art = collector.check_listing()
|
|
|
|
|
|
+ seform = SearchForm()
|
|
|
+
|
|
|
# check POST req
|
|
|
if form.validate_on_submit():
|
|
|
new_art = form.upload.data
|
|
|
@@ -157,18 +164,34 @@ def create():
|
|
|
flash('Listed!', category='success')
|
|
|
|
|
|
|
|
|
- return render_template('create_art.html', user = current_user, form = form, av_art = available_art)
|
|
|
+ return render_template('create_art.html', user = current_user, form = form, av_art = available_art, seform = seform)
|
|
|
|
|
|
@dashboards.route('/search', methods=['GET', 'POST'])
|
|
|
@login_required
|
|
|
def search():
|
|
|
- return render_template('search.html', user = current_user)
|
|
|
+ ##:
|
|
|
+ seform = SearchForm()
|
|
|
+
|
|
|
+ ##BUG: this may need to be on every view function for it to work...
|
|
|
+ if seform.validate_on_submit():
|
|
|
+ searchterm = seform.searchterm.data
|
|
|
+ if searchterm:
|
|
|
+ search_result = collector.search_art_objn(searchterm)
|
|
|
+ if search_result:
|
|
|
+ return render_template('search.html', user = current_user, seform = seform, sr = search_result)
|
|
|
+ search_result = collector.search_art_objc(searchterm)
|
|
|
+ if search_result:
|
|
|
+ return render_template('search.html', user = current_user, seform = seform, sr = search_result)
|
|
|
+
|
|
|
+
|
|
|
+ return render_template('search.html', user = current_user, seform = seform)
|
|
|
|
|
|
@dashboards.route('/detail', methods=['GET', 'POST'])
|
|
|
@login_required
|
|
|
def detail():
|
|
|
focus = None
|
|
|
form = BidForm()
|
|
|
+ seform = SearchForm()
|
|
|
|
|
|
# Collects details of the listing based on the
|
|
|
# focus pointer of the user
|
|
|
@@ -215,12 +238,15 @@ def detail():
|
|
|
detail = focus,
|
|
|
own_uname = owner_obj.username,
|
|
|
form = form,
|
|
|
- ibh = item_bid_hist
|
|
|
+ ibh = item_bid_hist,
|
|
|
+ seform = seform
|
|
|
)
|
|
|
|
|
|
@dashboards.route('/charge', methods=['POST'])
|
|
|
@login_required
|
|
|
def charge():
|
|
|
+ seform = SearchForm()
|
|
|
+
|
|
|
# Stripe charge POST request method
|
|
|
# Amount in cents
|
|
|
dbc_stripe = Stripe.query.filter_by(user_id = current_user.id).order_by(Stripe.id.desc()).first()
|
|
|
@@ -241,11 +267,12 @@ def charge():
|
|
|
# db dispatch for wallet top up
|
|
|
dispatch.top_up(current_user.id, raw_amount)
|
|
|
|
|
|
- return render_template('charge.html', user = current_user)
|
|
|
+ return render_template('charge.html', user = current_user, seform = seform)
|
|
|
|
|
|
@dashboards.route('/hashchain', methods=['GET'])
|
|
|
def hashchain():
|
|
|
hashchain = Hashchain.query.all()
|
|
|
txlist = TX.query.all()
|
|
|
+ seform = SearchForm()
|
|
|
|
|
|
- return render_template('hash.html', user = current_user, hashchain = hashchain, txlist = txlist)
|
|
|
+ return render_template('hash.html', user = current_user, hashchain = hashchain, txlist = txlist, seform = seform)
|