def get_comments(request, **kwargs): page = kwargs.get("page", None) post_id = kwargs.get("post_id", None) comment_id = kwargs.get("id", None) exhausted = False if post_id: comments_list = Post.objects.get( id=int(post_id)).comments.order_by('-time_created') else: comments_list = Comment.objects.all() if page: items, exhausted = paginate_items(comments_list, **kwargs) elif comment_id: items = comments_list.filter(id=comment_id) append_string = "" items = [i for i in items][::-1] for item in items: local_context = { 'comment': item, } append_string += render_to_string('modules/comment.html', local_context, context_instance=global_context( request, token_info=False)) local_context = { "append_string": append_string, "exhausted": exhausted, "post_id": post_id, } return json.dumps(local_context)
def get_comments(request, **kwargs): page = kwargs.get("page", None) post_id = kwargs.get("post_id", None) comment_id = kwargs.get("id", None) exhausted = False if post_id: comments_list = Post.objects.get(id = int(post_id)).comments.order_by('-time_created') else: comments_list = Comment.objects.all() if page: items, exhausted = paginate_items(comments_list, **kwargs) elif comment_id: items = comments_list.filter(id=comment_id) append_string = "" items = [i for i in items][::-1] for item in items: local_context = { 'comment' : item, } append_string += render_to_string('modules/comment.html', local_context, context_instance=global_context(request, token_info=False)) local_context = { "append_string" : append_string, "exhausted" : exhausted, "post_id" : post_id, } return json.dumps(local_context)
def get_posts(request, **kwargs): page = kwargs.get("page", None) wall_id = kwargs.get("wall_id", None) post_id = kwargs.get("id", None) exhausted = False user = request.user if wall_id: posts_list = get_my_posts( user, Wall.objects.filter(id=wall_id)[0]).order_by('-time_created') else: posts_list = get_my_posts(user).order_by('-time_created') if page: items, exhausted = paginate_items(posts_list, **kwargs) elif post_id: items = posts_list.filter(id=int(post_id)) append_string = "" for item in items: local_context = { 'post': item, 'show_post': 'True', } append_string += "<hr />" \ + render_to_string('modules/post.html', local_context, context_instance= global_context(request, token_info=False)) local_context = { "append_string": append_string, "exhausted": exhausted, "wall_id": wall_id, } return json.dumps(local_context)
def get_posts(request, **kwargs): page = kwargs.get("page", None) wall_id = kwargs.get("wall_id", None) post_id = kwargs.get("id", None) exhausted = False user = request.user if wall_id: posts_list = get_my_posts(user, Wall.objects.filter(id = wall_id)[0]).order_by('-time_created'); else: posts_list = get_my_posts(user).order_by('-time_created') if page: items, exhausted = paginate_items(posts_list, **kwargs) elif post_id: items = posts_list.filter(id = int(post_id)) append_string = "" for item in items: local_context = { 'post' : item, 'show_post' : 'True', } append_string += "<hr />" \ + render_to_string('modules/post.html', local_context, context_instance= global_context(request, token_info=False)) local_context = { "append_string" : append_string, "exhausted" : exhausted, "wall_id" : wall_id, } return json.dumps(local_context)