Skip to content

Commit

Permalink
photos have their own pages now
Browse files Browse the repository at this point in the history
  • Loading branch information
nickretallack committed Mar 14, 2011
1 parent c74077b commit f9db6a3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
*.swp
uploads
12 changes: 12 additions & 0 deletions circles/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ def __init__(self, *args, **kwargs):
super(Posting, self).__init__(*args, **kwargs)
self.discussion = Discussion()

@property
def photo_url(self):
return url_for('show_picture', posting_id=self.id)

postable = association(Posting, 'media')

class Event(db.Model):
Expand Down Expand Up @@ -675,4 +679,12 @@ def make_dirs_for(filename):
if not os.path.isdir(directory):
os.makedirs(directory)

@app.route('/pictures/<int:posting_id>')
def show_picture(posting_id):
posting = get_required(Posting, posting_id)
circle = posting.circle
you = check_access(circle, True)
return render('photo.html', circle=circle, posting=posting, you=you)


# -------------------------------- END ------------------------------
1 change: 1 addition & 0 deletions circles/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ textarea {width:100%; display:block}
.invitation-link {font-size:16pt}
.invitation-link textarea {min-width:50ex; height:2em; border:none}
.discussion {border-bottom:1px solid #eee; padding:1ex 0}
.picture {text-align:center}
2 changes: 1 addition & 1 deletion circles/templates/circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2>Discussion</h2>

<ul >{% for posting in postings %}
{% if posting.association.type == 'photos' %}
<img src="{{posting.media.thumbnail(200,200)}}">
<a href="{{posting.photo_url}}"><img src="{{posting.media.thumbnail(200,200)}}"></a>
{% endif %}
{{ render_discussion(posting.discussion, url_for('reply_to_posting', posting_id=posting.id), has_membership)}}
{% endfor %}</ul>
Expand Down
8 changes: 8 additions & 0 deletions circles/templates/photo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends 'base.html' %}
{% from 'macros.html' import link %}

{% block content %}
<p>This picture was posted to {{link(circle)}}.</p>
<div class="picture"><img src="{{posting.media.file_url()}}"></div>

{% endblock %}

0 comments on commit f9db6a3

Please sign in to comment.