瀏覽代碼

working on create art option

control 3 年之前
父節點
當前提交
da288be72e
共有 2 個文件被更改,包括 14 次插入2 次删除
  1. 11 1
      app/dashboards.py
  2. 3 1
      app/templates/create_art.html

+ 11 - 1
app/dashboards.py

@@ -76,6 +76,15 @@ 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
+    available_art = [art for art in owned_art if art.filehash not in listed_art]
+    print(listed_art)
+    print(available_art)
+
    # check POST req
     if form.validate_on_submit():
         new_art = form.upload.data
@@ -91,8 +100,9 @@ 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
 
-    return render_template('create_art.html', user = current_user, form = form)
+    return render_template('create_art.html', user = current_user, form = form, av_art = available_art)
 	
 # Pop Ups
 @dashboards.route('/modal_home')

+ 3 - 1
app/templates/create_art.html

@@ -109,7 +109,9 @@ $(function(){
           <span class="input-group-text">Select Art in Platform</span>  
           <select class="btn btn-secondary dropdown-toggle Closing-date-input-size" name="web_group" required aria-invalid="false"> 
             <option value="cng-555">Select here</option>
-            <option name="web_group" value="bought_art">bought_Art</option>
+            {% for art in av_art %}
+            <option name="web_group" value="{{art.name}}">{{art.name}}</option>
+            {% endfor %}
           </select>
         </div>
       </div>