using batch filter instead of modulus if statement
This commit is contained in:
parent
ef20bb2200
commit
18fe53559b
21
main.py
21
main.py
@ -19,16 +19,29 @@ def music():
|
|||||||
@app.route('/art')
|
@app.route('/art')
|
||||||
def art():
|
def art():
|
||||||
art_collection = db.collection(u'art')
|
art_collection = db.collection(u'art')
|
||||||
|
#art_tags_collection = db.collection(u'art_tags')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
docs = art_collection.get()
|
pics = art_collection.get()
|
||||||
|
#tags = art_tags_collection.get()
|
||||||
except google.cloud.exceptions.NotFound:
|
except google.cloud.exceptions.NotFound:
|
||||||
return 'no such document'
|
return 'no such document'
|
||||||
|
|
||||||
|
#categories = []
|
||||||
|
#for tag in tags:
|
||||||
|
#taglist = {
|
||||||
|
#tag.to_dict()['name'] : []
|
||||||
|
#}
|
||||||
|
#print(tag.to_dict())
|
||||||
|
#categories.append(taglist)
|
||||||
|
|
||||||
|
#print(categories)
|
||||||
|
|
||||||
images = []
|
images = []
|
||||||
for doc in docs:
|
for doc in pics:
|
||||||
image = doc.to_dict()
|
#image = doc.to_dict()
|
||||||
images.append(image)
|
images.append(doc.to_dict())
|
||||||
|
#categories[categories.index(image['tag'])].append(image)
|
||||||
|
|
||||||
return render_template('art.html', staticroot = staticbucketurl, images=images)
|
return render_template('art.html', staticroot = staticbucketurl, images=images)
|
||||||
|
|
||||||
|
@ -5,13 +5,20 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% for image in images %}
|
{#{% for tag in tags %}#}
|
||||||
{% if loop.index0 % 3 == 0 %}<div class="row">{% endif %}
|
|
||||||
|
{% 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">
|
<div class="card col-pad-4">
|
||||||
<img src="{{ staticroot }}art/{{ image.file_name }}.jpg" alt="{{ image.file_name }}" class="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>
|
<p><b>{{ image.description }}</b></p>
|
||||||
</div>
|
</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 %}
|
||||||
|
|
||||||
|
{#{% endfor %}#}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user