Skip to content

Commit

Permalink
Gallery handles uploaded images
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolerd committed Aug 13, 2015
1 parent d6f3602 commit c82a2e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions project/pages/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
from flask import render_template
from project.blueprints import pages_app
from project.models import Page
from project.models import Page, UploadedImage


# All pages are hardcoded for now

@pages_app.route("/")
def mainpage():
page = Page.bl.get(Page.TYPE.MAINPAGE)
return render_template('pages/mainpage.html', blocks=page.blocks)
images = (
UploadedImage.query
.filter(
UploadedImage.img_category == UploadedImage.IMG_CATEGORY.gallery
)
.all()
)
return render_template(
'pages/mainpage.html',
blocks=page.blocks,
images=images,
)


@pages_app.route('/projects/')
Expand Down
7 changes: 7 additions & 0 deletions project/templates/pages/mainpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
</div>

<div class="container" id="gallery">
{% for image in images %}
<a href="/media/{{ image.img_category.name }}/full/{{ image.name.hex }}.{{ image.ext }}"
title="{{ image.title }}">
<img src="/media/{{ image.img_category.name }}/thumb/{{ image.name.hex }}.{{ image.ext }}"
alt="{{ image.description }}">
</a>
{% endfor %}
<a href="https://farm1.static.flickr.com/304/19265407504_1b7a4422ed_b.jpg"
title="Broken Chain">
<img src="https://farm1.static.flickr.com/304/19265407504_1b7a4422ed_s.jpg">
Expand Down

0 comments on commit c82a2e5

Please sign in to comment.