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 mark_viewed(request): """ Mark all messages as read """ message_id = request.POST.get('message_id', None) if request.method == 'POST' and message_id: Message.mark_viewed(int(message_id), request.app_user) if request.is_ajax(): return HttpResponse('OK') return HttpResponseRedirect(reverse('app_index'))
def mark_read(request): """ Mark all messages as read """ message_id = request.REQUEST.get('message_id', None) if message_id: Message.mark_read(int(message_id), request.app_user, 'all' in request.REQUEST) if request.is_ajax(): return HttpResponse('OK') return HttpResponseRedirect(reverse('app_index'))
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())