Skip to content

Commit

Permalink
fix #7 -- hide posts of other users
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 6, 2015
1 parent c98551e commit 961d151
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
31 changes: 30 additions & 1 deletion COMET/__init__.py
Expand Up @@ -226,9 +226,38 @@ def index():
'assets')):
return redirect('/setup')
context = {}
context['site'] = _site

n = request.args.get('all')
if n is None:
wants_now = None
else:
wants_now = n == '1'

if wants_now is None and current_user.wants_all_posts:
wants = True
else:
wants = wants_now

if current_user.can_edit_all_posts and wants:
posts = _site.posts
pages = _site.pages
else:
wants = False
posts = []
pages = []
for p in _site.timeline:
if p.meta('author.uid') and p.meta('author.uid') != str(current_user.uid):
continue
if p.use_in_feeds:
posts.append(p)
else:
pages.append(p)

context['posts'] = posts
context['pages'] = pages
context['title'] = 'Posts & Pages'
context['permalink'] = '/'
context['wants'] = wants
return render('comet_index.tmpl', context)

@app.route('/setup')
Expand Down
25 changes: 23 additions & 2 deletions COMET/templates/mako/comet_index.tmpl
Expand Up @@ -4,6 +4,11 @@
.list-group {
margin-top: 10px;
}

h2 {
margin-top: 20px;
padding-top: 0;
}
</style>
</%block>
<%block name="extra_js">
Expand All @@ -20,6 +25,22 @@ $('#deleteModal').on('show.bs.modal', function (event) {
</%block>
<%block name="content">

<div class="well well-sm">
Show posts of:
<div class="btn-group" role="group">
% if wants:
<a href="/?all=0" class="btn btn-default"><i class="fa fa-fw fa-user"></i></a>
<a href="/?all=1" class="btn btn-default active"><i class="fa fa-fw fa-users"></i></a>
% elif not current_user.can_edit_all_posts:
<a href="#" class="btn btn-default active"><i class="fa fa-fw fa-user"></i></a>
<a href="#" class="btn btn-default disabled"><i class="fa fa-fw fa-users"></i></a>
% else:
<a href="/?all=0" class="btn btn-default active"><i class="fa fa-fw fa-user"></i></a>
<a href="/?all=1" class="btn btn-default"><i class="fa fa-fw fa-users"></i></a>
% endif
</div>
</div>

<div class="row">
<div class="col-md-6">
<h2 style="text-align: center;">Posts</h2>
Expand All @@ -28,7 +49,7 @@ $('#deleteModal').on('show.bs.modal', function (event) {
<span class="input-group-btn"><button type="submit" class="btn btn-success"><i class="fa fa-file-o"></i> Create Post</button></span>
</form>
<div class="list-group">
% for p in site.posts:
% for p in posts:
<div class="list-group-item">
<h3 class="media-heading">${p.title()}</h3>
<small>Date: ${p.date}</small>
Expand All @@ -50,7 +71,7 @@ $('#deleteModal').on('show.bs.modal', function (event) {
</form>
<div class="page_holder"></div>
<div class="list-group">
% for p in site.pages:
% for p in pages:
<div class="list-group-item">
<h3 class="media-heading">${p.title()}</h3>
<small>Date: ${p.date}</small>
Expand Down
2 changes: 1 addition & 1 deletion COMET/users.json
Expand Up @@ -9,7 +9,7 @@
"password": "$2a$12$.qMCcA2uOo0BKkDtEF/bueYtHjcdPBmfEdpxtktRwRTgsR7ZVTWmW",
"realname": "Website Administrator",
"username": "admin",
"wants_all_posts": true
"wants_all_posts": false
},
"2": {
"active": true,
Expand Down

0 comments on commit 961d151

Please sign in to comment.