Просмотр исходного кода

home page, backend 3/4 complete

control 3 лет назад
Родитель
Сommit
0661cdc5f0
3 измененных файлов с 22 добавлено и 7 удалено
  1. BIN
      app/database.db
  2. 15 4
      app/logic.py
  3. 7 3
      app/templates/home.html

BIN
app/database.db


+ 15 - 4
app/logic.py

@@ -13,6 +13,20 @@ logic = Blueprint('logic', __name__)
 @logic.route('/', methods=['GET', 'POST'])
 @login_required
 def home():
+
+    # owned groups
+    bgroups = Groups.query.filter_by(owner=current_user.id).all()
+    # owned bookmarks
+    bmarks = Bookmark.query.filter_by(owner=current_user.id).all()
+
+    bb_dic = dict() # dict of lists
+    for bg in bgroups:
+        inter_list = list()
+        for bm in bmarks:
+            if bm.group == bg.group:
+                inter_list.append(bm)
+        bb_dic[bg.group] = inter_list
+
     if request.method == "POST":
         username = request.form.get('username')
         passwd = request.form.get('password')
@@ -46,15 +60,13 @@ def home():
             db.session.commit()
             flash('Profile Pic updated!', category='success')
 
-    return render_template('home.html', user=current_user)
+    return render_template('home.html', user=current_user, bdic=bb_dic)
 
 @logic.route('/create', methods=['GET', 'POST'])
 @login_required
 def create():
 
     bgroups = Groups.query.filter_by(owner=current_user.id).all()
-    for bg in bgroups:##
-        print(bg.group)##
 
     if request.method == 'POST':
         wlink = request.form.get('web_link')
@@ -72,7 +84,6 @@ def create():
                 new_group = Groups(owner=current_user.id, group=wgroup)
                 db.session.add(new_group)
             db.session.add(new_link)
-            print(wlink, wname, wgroup, ngroup, wstatus)##
             db.session.commit()
             flash('New Bookmark added!', category='success')
 

+ 7 - 3
app/templates/home.html

@@ -187,25 +187,29 @@ ul {
             </div>
         </div>
         <!-- Code: Each Group of Box-->
+        {% for bg, bml in bdic.items(): %}
         <div class="col-lg-4 col-md-4 col-sm-4">
             <div class="inner_box">
-                <h3>(Group1)</h3>
+                <h3>{{ bg }}</h3>
                 <hr>
                 <!-- Code: Each Link in the Box-->
+                {% for bm in bml: %}
                 <ul class="list">
-                    <li><span class="bull">(ICON) (NAME) (STATUS)</span></li>
+                    <li><span class="bull">ICON {{ bm.name }} {{ bm.status }}</span></li>
                     <li class="href_link_button">
-                        <a href="(Web_link)">
+                        <a href="{{ bm.link }}">
                             <img src="static/logo/link_logo.png"width="25" height="25">
                         </a>
                         <button type="submit">Edit</button>
                     </li>
                 </ul>
+                {% endfor %}
                 <!-- (End) Code: Each Link in the Box (End)-->
                 <br>
             </div>
         </div>
         <!--(End) Code: Each Group of Box (End)-->
+        {% endfor %}
         <div class="clearfix"></div>
     </div>
     <div class="clearfix"></div>