def comment(request): if C.checkLoginAdmin(request.session.get('uInfo', False)) == False: return HttpResponseRedirect('/signin/') else: context = {} cid = int(request.GET.get('cid', 0)) status = cgi.escape(request.GET.get('status', 'pass')) updateStatus = cgi.escape(request.GET.get('update_status', '')) if updateStatus != '' and cid != 0: res = False if updateStatus == 'delete': res = Comment.objects.filter(comment_id=cid).delete() else: upComment = Comment.objects.get(comment_id=cid) upComment.status = updateStatus res = upComment.save() msg = u'操作成功' if res == False: msg = u'操作失败' context = { 'msg' : C.message(msg, '/manage_comment/?status=' + str(status)) } return render(request, manageThemeDir + 'comment.html', context) if status == 'pass': commentList = Comment.objects.filter(status='approved').order_by('-comment_id').all() else: commentList = Comment.objects.filter(status='waiting').order_by('-comment_id').all() paginator = Paginator(commentList, 10) page = int(request.GET.get('page', 1)) try: pagebar = paginator.page(page) except PageNotAnInteger: pagebar = paginator.page(1) except EmptyPage: pagebar = paginator.page(paginator.num_pages) articleList = [] if pagebar: aidList = [] for item in pagebar: aidList.append(item.article_id) articleList = Article.objects.filter(article_id__in=aidList).all() for item in pagebar: for it in articleList: if item.article_id == it.article_id: item.article = it.title context = { 'status' : status, 'pagebar' : pagebar } return render(request, manageThemeDir + 'comment.html', context)