def read_post(request, post_id, slug, comment_id=None): """ Display post and its comments """ try: try: max_comments = 200 if int(request.GET.get( 'limit', 200)) > 200 else request.GET.get('limit', 200) except: max_comments = 200 if request.app_user.is_authenticated() and 'message_id' in request.GET: Message.mark_read(request.GET['message_id'], request.app_user, False) post_id = long(post_id) comment_id = long(comment_id) if comment_id else None post = Post.read_post(post_id, slug, request.app_user, comment_id, max_comments) except Post.DoesNotExist: raise Http404() markdown_help_text = MARK_DOWN_TEXT return render_response(request, 'app/post.html', locals())
def rate_post(request, post_id, slug, comment_id=None): """ Display post web page and rating bar """ try: post_id = long(post_id) post = Post.read_post(post_id, slug, request.app_user, max_comments=0) if post.is_text_post(): return HttpResponsePermanentRedirect(post.get_absolute_url()) except Post.DoesNotExist: raise Http404() return render_response(request, 'app/rate_post.html', locals())
def rate_post(request, post_id, slug, comment_id=None): """ Display post web page and rating bar """ try: post_id = long(post_id) post = Post.read_post(post_id, slug, request.app_user, max_comments=0) if post.is_text_post(): return HttpResponsePermanentRedirect(post.get_absolute_url()) except Post.DoesNotExist: raise Http404() return render_response(request, 'app/rate_post.html', locals())
def read_post(request, post_id, slug, comment_id=None): """ Display post and its comments """ try: try: max_comments = 200 if int(request.GET.get('limit', 200)) > 200 else request.GET.get('limit', 200) except: max_comments = 200 if request.app_user.is_authenticated() and 'message_id' in request.GET: Message.mark_read(request.GET['message_id'], request.app_user, False) post_id = long(post_id) comment_id = long(comment_id) if comment_id else None post = Post.read_post(post_id, slug, request.app_user, comment_id, max_comments) except Post.DoesNotExist: raise Http404() markdown_help_text = MARK_DOWN_TEXT return render_response(request, 'app/post.html', locals())