Exemplo n.º 1
0
def detail(request):
	
	aid = cgi.escape(request.GET.get('aid'))
	url = request.get_host()

	detail = []
	if C.isset(aid):
		detail = Article.objects.get(article_id=aid)
		detail.author  = User.objects.get(user_id=detail.author).username
		detail.content = detail.content.replace('\t', '').replace('\n', '').replace(' ', '')
	
	navList      = C.getNavList()
	userInfo     = request.session.get('uInfo', '')
	commentHtml  = commentTree(commentList, 0, False)
	commentList  = Comment.objects.filter(article_id=aid)

	del commentList

	upArticle = Article.objects.get(article_id=aid)
	upArticle.look_count = upArticle.look_count+1
	upArticle.save()

	context = {
		'userinfo'     : userInfo,
		'detail'       : detail,
		'navList'      : navList,
		'url'          : url,
        'aid'          : aid,
		'commentHtml'  : commentHtml,
		'themeHeader'  : C.getThemePath() + '/Public/header.html',
		'themeFooter'  : C.getThemePath() + '/Public/footer.html'
	}

	return render(request, C.getThemePath() + 'detail.html', context)
Exemplo n.º 2
0
def index(request):
	
	url = request.get_host()
	cid = request.GET.get('cid')
	
	if C.isset(cid) == 0:
		cid = 0

	navList = C.getNavList()
	
	if request.method == 'POST':
		articleList = Article.objects.filter(title__icontains=cgi.escape(request.POST.get('word'))).order_by('-article_id')
	
	elif cid == 0:
		articleList = Article.objects.all().order_by('-article_id')
	
	else:
		sql = 'SELECT * FROM "' + Meta.db_table + '_article" AS article LEFT JOIN "' + Meta.db_table
		sql += '_relation" AS relation ON article.article_id=relation.aid WHERE relation.cid=' + cgi.escape(cid)
		#sql += " AND article.title LIKE '%%" + request.POST.get('word') + "%%'"
		sql += ' ORDER BY article_id DESC'
		articleList = Article.objects.raw(sql)
		articleList = list(articleList)
	
	paginator  = Paginator(articleList, 5)
	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)

	categoryList  = C.getCategoryList()
	userInfo      = request.session.get('uInfo', '')

	contentDateList = Article.objects.order_by('created').values('created').distinct()

	context = {
		'url'              : url,
		'pagebar'          : pagebar,
		'navList'          : navList,
		'userinfo'         : userInfo,
		'cid'              : int(cid),
		'articleList'      : articleList,
        'categoryList'     : categoryList,
		'webInfo'          : C.getWebInfo(),
		'contentDateList'  : contentDateList,
		'themeHeader'      : C.getThemePath() + '/Public/header.html',
		'themeFooter'      : C.getThemePath() + '/Public/footer.html'
	}

	return render(request, C.getThemePath() + 'index.html', context)
Exemplo n.º 3
0
def signin(request):
    
	navList = C.getNavList()