def post_show(request, pid): """ Displays a post and its children """ user = request.user # populate the session data sess = middleware.Session(request) tab = "posts" pill = sess.get_tab() auth = user.is_authenticated() layout = settings.USER_PILL_BAR if auth else settings.ANON_PILL_BAR params = html.Params(tab=tab, pill=pill, layout=layout) query = get_post_manager(request) try: root = query.get(id=pid) if not root.top_level: return html.redirect( root.get_absolute_url() ) # update the views for the question models.update_post_views(post=root, request=request) counts = sess.get_counts() except models.Post.DoesNotExist, exc: messages.warning(request, 'The post that you are looking for does not exists. Perhaps it was deleted!') return html.redirect("/")
def post_show(request, pid): "Returns a question with all answers" user = request.user # populate the session data sess = middleware.Session(request) tab = "posts" pill = sess.get_tab() auth = user.is_authenticated() layout = settings.USER_PILL_BAR if auth else settings.ANON_PILL_BAR params = html.Params(tab=tab, pill=pill, layout=layout) query = get_post_manager(request) try: root = query.get(id=pid) # update the views for the question models.update_post_views(post=root, request=request, minutes=const.POST_VIEW_UPDATE) counts = sess.get_counts() except models.Post.DoesNotExist, exc: messages.warning(request, 'The post that you are looking for does not exists. Perhaps it was deleted!') return html.redirect("/")
def post_show(request, pid): "Returns a question with all answers" user = request.user # populate the session data sess = middleware.Session(request) tab = "posts" pill = sess.get_tab() auth = user.is_authenticated() layout = settings.USER_PILL_BAR if auth else settings.ANON_PILL_BAR params = html.Params(tab=tab, pill=pill, layout=layout) query = get_post_manager(request) try: root = query.get(id=pid) # update the views for the question models.update_post_views(post=root, request=request, minutes=const.POST_VIEW_UPDATE) counts = sess.get_counts() except models.Post.DoesNotExist, exc: messages.warning( request, 'The post that you are looking for does not exists. Perhaps it was deleted!' ) return html.redirect("/")
def post_show(request, pid): """ Displays a post and its children """ user = request.user # populate the session data sess = middleware.Session(request) tab = "posts" pill = sess.get_tab() auth = user.is_authenticated() layout = settings.USER_PILL_BAR if auth else settings.ANON_PILL_BAR params = html.Params(tab=tab, pill=pill, layout=layout) query = get_post_manager(request) try: root = query.get(id=pid) if not root.top_level: return html.redirect(root.get_absolute_url()) # update the views for the question models.update_post_views(post=root, request=request) counts = sess.get_counts() except models.Post.DoesNotExist, exc: messages.warning( request, 'The post that you are looking for does not exists. Perhaps it was deleted!' ) return html.redirect("/")
def linkout(request, pid): "Used to be able to count the views for a linkout" post = models.Post.objects.get(id=pid) models.update_post_views(post=post, request=request) post.set_rank() post.save() if post.url: return html.redirect(post.url) else: message.error(request, 'linkout used on a post with no url set %s' % post.id) return html.redirect("/")
def linkout(request, pid): "Used to be able to count the views for a linkout" post = models.Post.objects.get(id=pid) models.update_post_views(post=post, request=request) post.set_rank() post.save() if post.url: return html.redirect(post.url) else: messages.error(request, 'linkout used on a post with no url set %s' % post.id) return html.redirect("/")
def post_show(request, pid): "Returns a question with all answers" user = request.user query = get_post_manager(request) try: root = query.get(id=pid) # update the views for the question models.update_post_views(post=root, request=request, hours=settings.POST_VIEW_RANK_GAIN) except models.Post.DoesNotExist, exc: messages.warning(request, 'The post that you are looking for does not exists. Perhaps it was deleted!') return html.redirect("/")
def blog_redirect(request, pid): "Used to be able to count the views for a blog" blog = models.Post.objects.get(id=pid, type=POST_BLOG) models.update_post_views(post=blog, request=request, hours=settings.BLOG_VIEW_RANK_GAIN) # 12 hour rank change return html.redirect( blog.get_absolute_url() )