Explorar o código

Fixed current bid bug; not showing on detail and market page

control %!s(int64=3) %!d(string=hai) anos
pai
achega
441f0c26f1

+ 0 - 1
app/dashboards.py

@@ -105,7 +105,6 @@ 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)
-                flash('Minted & Listed!', category='success')
 
         # For re-Listing Art
         if not new_art:

BIN=BIN
app/database (pre-minted).db


BIN=BIN
app/database.db


+ 7 - 1
app/dispatch.py

@@ -4,6 +4,7 @@ import sqlalchemy
 import os
 
 from datetime import datetime
+from flask import flash
 from flask_login import current_user
 
 from .models import Hashchain, Art, List, TX , User, Bids, List
@@ -63,7 +64,11 @@ def mint(designated_fn, art_name, art_desc, min_price, buyout_price, close_date)
             )
     db.session.add(new_listing)
 
-    db.session.commit() 
+    try:
+        db.session.commit() 
+        flash('Minted & Listed!', category='success')
+    except Exception:
+        flash('Error Minting! Cannot Add an Already Existing File!', category='error')
 
 
 def list_item(designated_fn, art_name, art_desc, min_price, buyout_price, close_date, filehash):
@@ -150,6 +155,7 @@ def enter_bid(user_bid, focus):
     # update List table
     dbcall = List.query.filter_by(filehash = current_user.focus).first()
     dbcall.min_price = user_bid
+    dbcall.cur_bid = user_bid
     db.session.commit()
 
 def save_pp(pp_path):

+ 2 - 1
app/lib/collector.py

@@ -28,7 +28,8 @@ def join_art_list_table():
                             l.out_price, # [8] minimum buyout price
                             l.timeout, # [9] closing bidding date
                             l.list_date, # [10] listing date
-                            l.filehash # [11] listings/art filehash
+                            l.filehash, # [11] listings/art filehash
+                            l.cur_bid # [12] listing's current bid
                         ])
     return return_list
 

+ 1 - 1
app/models.py

@@ -35,7 +35,7 @@ class Art(db.Model):
 
 class List(db.Model):
     id = db.Column(db.Integer, primary_key=True)
-    filehash = db.Column(db.String(64)) # sha256 hash # one-to-one from Art
+    filehash = db.Column(db.String(64), unique=True) # sha256 hash # one-to-one from Art
     seller = db.Column(db.Integer)
     min_price = db.Column(db.Float)
     out_price = db.Column(db.Float)

BIN=BIN
app/static/repository/3YdXeM6xZpUbmj3W.jpg


BIN=BIN
app/static/repository/7PE7S1elVmnyrrDX.jpeg


BIN=BIN
app/static/repository/E40pw7hr8Xv4yBBS.jpg


BIN=BIN
app/static/repository/HXk4s8hcG6T0SvsO.jpg


BIN=BIN
app/static/repository/SmAmbRZwkxOL3jWD.jpg


BIN=BIN
app/static/repository/hgWeov20otnWlBAp.jpg


BIN=BIN
app/static/repository/vaUxGM7yQfkqwRan.jpg


BIN=BIN
app/static/uploads/LzMUWPV3r1ZUb4SI.jpeg


+ 1 - 1
app/templates/create_art.html

@@ -17,7 +17,7 @@
       </div>
       <!--Input Minimum Price-->
       <div class="create_art-input-box">
-        {{ form.min_price(placeholder="Enter Minimum Price (USD)", class="form-control create_art-input") }}
+        {{ form.min_price(placeholder="Enter Minimum Price (USD)", class="form-control create_art-input", min=1) }}
       </div> 
       <!--Input Buyout Price-->
       <div class="create_art-input-box">

+ 1 - 1
app/templates/detail_art.html

@@ -15,7 +15,7 @@
             <p class="lead">{{ detail[1] }}</p>
             <div class="fs-5 mb-5">
               <!-- Price & Name-->
-              <span class="text-decoration-line-through">Current Bid Price: (Current Bid Price) USD</span><br>
+              <span class="text-decoration-line-through">Current Bid Price: {{ detail[12] }} USD</span><br>
               <span class="text-decoration-line-through">Buyout Price: {{ detail[8] }} USD</span><br>
               <span class="text-decoration-line-through">Minimum Price: {{ detail[7] }} USD</span><br>
               <span class="text-decoration-line-through">Creator: {{ detail[3] }}</span><br>

+ 1 - 1
app/templates/market.html

@@ -23,7 +23,7 @@
                 <b>{{art[0]}}</b>
             </div>
             <div class="row">
-                <p id="market_item_text_left">Current Bid</b>
+                <p id="market_item_text_left">Current Bid {{art[12]}}</b>
                 <p id="market_item_text_right">(Price) <span class="price-span">USD</span></b>
             </div>
             <div class="row">