From 18fe53559b400e8f03f1c6b950f4e2b13414372d Mon Sep 17 00:00:00 2001
From: aj <andrewjpack@gmail.com>
Date: Tue, 19 Feb 2019 11:52:25 +0000
Subject: [PATCH] using batch filter instead of modulus if statement

---
 main.py            | 21 +++++++++++++++++----
 templates/art.html | 17 ++++++++++++-----
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/main.py b/main.py
index 28ee83c..11a53a3 100644
--- a/main.py
+++ b/main.py
@@ -19,16 +19,29 @@ def music():
 @app.route('/art')
 def art():
     art_collection = db.collection(u'art')
+    #art_tags_collection = db.collection(u'art_tags')    
     
     try:
-        docs = art_collection.get()
+        pics = art_collection.get()
+        #tags = art_tags_collection.get()
     except google.cloud.exceptions.NotFound:
         return 'no such document'
+
+    #categories = []
+    #for tag in tags:
+        #taglist = {
+            #tag.to_dict()['name'] : []
+        #}
+        #print(tag.to_dict())
+        #categories.append(taglist)
     
+    #print(categories)
+
     images = []
-    for doc in docs:
-        image = doc.to_dict()
-        images.append(image)
+    for doc in pics:
+        #image = doc.to_dict()
+        images.append(doc.to_dict())
+        #categories[categories.index(image['tag'])].append(image)
 
     return render_template('art.html', staticroot = staticbucketurl, images=images)
 
diff --git a/templates/art.html b/templates/art.html
index 923d51f..d767325 100644
--- a/templates/art.html
+++ b/templates/art.html
@@ -4,14 +4,21 @@
 {% block title %}art{% endblock %}
 
 {% block content %}	
-
-	{% for image in images %}	
-	{% if loop.index0 % 3 == 0 %}<div class="row">{% endif %}
+	
+{#{% for tag in tags %}#}
+	
+	{% for row in images|batch(3) %}
+	<div class="row">
+		{% for image in row %}	
+	{#{% if loop.index0 % 3 == 0 %}<div class="row">{% endif %}#}
 		<div class="card col-pad-4">
 			<img src="{{ staticroot }}art/{{ image.file_name }}.jpg" alt="{{ image.file_name  }}" class="col-pad-4">
 			<p><b>{{ image.description  }}</b></p>
 		</div>
-	{% if loop.index % 3 == 0 or loop.last %}</div>{% endif %}
-
+	{#{% if loop.index % 3 == 0 or loop.last %}</div>{% endif %}#}
+		{% endfor %}
+	</div>
 	{% endfor %}
+
+{#{% endfor %}#}
 {% endblock %}