Skip to content
Permalink
Browse files
fix #7 -- hide posts of other users
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 6, 2015
1 parent c98551e commit 961d15167de1851809cb71417ad54942b5eae731
Showing with 54 additions and 4 deletions.
  1. +30 −1 COMET/__init__.py
  2. +23 −2 COMET/templates/mako/comet_index.tmpl
  3. +1 −1 COMET/users.json
@@ -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')
@@ -4,6 +4,11 @@
.list-group {
margin-top: 10px;
}

h2 {
margin-top: 20px;
padding-top: 0;
}
</style>
</%block>
<%block name="extra_js">
@@ -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>
@@ -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>
@@ -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>
@@ -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,

0 comments on commit 961d151

Please sign in to comment.