Forráskód Böngészése

started work on Markets page

control 3 éve
szülő
commit
cfde5b3552

+ 14 - 3
app/dashboards.py

@@ -1,7 +1,7 @@
 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, Art
+from .models import User, Art, List
 from . import db
 
 from . import dispatch
@@ -13,7 +13,18 @@ dashboards = Blueprint('dashboards', __name__)
 # Main Pages
 @dashboards.route('/', methods=['GET', 'POST'])
 def market():
-    return render_template('market.html', user=current_user)
+
+    
+    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 render_template('market.html', user=current_user, listings = return_list)
 	
 @dashboards.route('/profile', methods=['GET', 'POST'])
 @login_required
@@ -63,7 +74,7 @@ def create():
 @dashboards.route('/modal_home')
 @login_required
 def modal_home():
-    return render_template('detail_art_for_home.html', user=current_user)
+    return render_template('detail_art_for_market.html', user=current_user)
 
 @dashboards.route('/modal_profile')
 @login_required

+ 3 - 3
app/models.py

@@ -27,14 +27,14 @@ class Art(db.Model):
     id = db.Column(db.Integer, primary_key=True)
     name = db.Column(db.String(200))
     description = db.Column(db.String(200))
-    filehash = db.Column(db.String(64)) # sha256 hash
+    filehash = db.Column(db.String(64), unique=True) # sha256 hash # parent foreign key
     owner = db.Column(db.Integer)
     creator = db.Column(db.Integer)
     dname = db.Column(db.String(20))
 
 class List(db.Model):
     id = db.Column(db.Integer, primary_key=True)
-    filehash = db.Column(db.String(64)) # sha256 hash
+    filehash = db.Column(db.String(64)) # sha256 hash # one-to-one from Art
     seller = db.Column(db.Integer)
     min_price = db.Column(db.Float)
     out_price = db.Column(db.Float)
@@ -43,7 +43,7 @@ class List(db.Model):
 
 class Bids(db.Model):
     id = db.Column(db.Integer, primary_key=True)
-    filehash = db.Column(db.String(64)) # sha256 hash
+    filehash = db.Column(db.String(64)) # sha256 hash # one-to-many from List
     buyer = db.Column(db.Integer)
     bid_price = db.Column(db.Float)
     bid_date = db.Column(db.DateTime(timezone=True), default=func.now()) 

+ 3 - 3
app/templates/detail_art_for_home.html → app/templates/detail_art_for_market.html

@@ -1,4 +1,4 @@
-{% extends "home.html" %}
+{% extends "market.html" %}
 
 {% block modal %}
 <div class="modal" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
@@ -50,7 +50,7 @@
             <label for="Bidding Price"></label>
             <p>At the backend needs to record the bidder nickname and time. And the record will be showing at the bid history table</p>
             <button type="button" class="btn btn-primary">Bid</button>
-            <a href="{{url_for('dashboards.home')}}">Close</a>
+            <a href="{{url_for('dashboards.market')}}">Close</a>
         </div>
       </div>
       <div class="modal-footer">
@@ -64,4 +64,4 @@
         $("#exampleModal").modal("show")
     })
 </script>
-{% endblock %}
+{% endblock %}

+ 5 - 2
app/templates/market.html

@@ -2,12 +2,15 @@
 
 {% block content %}
 <br><br><br><br><br>
-<h1>Home</h1>
+<h1>Art Market</h1>
 
 <p>Auction for all Art</p>
-<p>1. Art Name</p>
+{% for art in listings %}
+<p>{{art[0]}}</p>
+<img src="static/repository/{{art[4]}}">
 <p>2. Art Image (Click the photo will go to pop up detail art page)</p>
 <p>3. Art current bid price</p>
+{% endfor %}
 
 <a href="{{url_for('dashboards.modal_home')}}">Popup</a>