def charge_logs(request, page = "1"): charge_n_logs = Charge_normal_logs.objects.filter(user = request.user ) log_list = DBUtils.divide_page(charge_n_logs, 10, int(page)) log_list.count = int(math.ceil(charge_n_logs.count() / float( '%.2f' % 10))); return render_to_response('chargelogs.html',{'current_app' : current_app, 'current_tab' : request.path, 'log_list' : log_list, },context_instance=RequestContext(request))
def qs_mine_page(request, page = 1): if request.user.is_authenticated(): myQuestions = Question.objects.filter(user=request.user) #@UndefinedVariable for question in myQuestions: question.anwser_count = question.anwser_set.all().count(); myquest_list = DBUtils.divide_page(myQuestions,10, page) return render_to_response('faqs_mytasks.html', {'myquest_list':myquest_list },context_instance=RequestContext(request) ) else: return HttpResponseRedirect("/login/")
def charge_logs(request, page="1"): charge_n_logs = Charge_normal_logs.objects.filter(user=request.user) log_list = DBUtils.divide_page(charge_n_logs, 10, int(page)) log_list.count = int(math.ceil(charge_n_logs.count() / float('%.2f' % 10))) return render_to_response('chargelogs.html', { 'current_app': current_app, 'current_tab': request.path, 'log_list': log_list, }, context_instance=RequestContext(request))
def qs_tag_quest(request, *args, **kwargs): tagId = kwargs.pop('id',None) page = kwargs.pop('page',1) if tagId != None: question_tag = Question_Tag.objects.get(id=int(tagId)) #@UndefinedVariable tag_quests = Question.objects.filter(tags=question_tag) #@UndefinedVariable for tag_quest in tag_quests: tag_quest.anwser_count = tag_quest.anwser_set.all().count(); question_list = DBUtils.divide_page(tag_quests, 10, int(page)) return render_to_response('faqs_tag_quest.html',{'question_list':question_list,'question_tag':question_tag},context_instance=RequestContext(request))
def getQuestionsDynamicSql(sort, type): operatorSql = {0:''' select a.id,a.title,a.visits,a.quest_time,c.type_name,a.lastest_anwser_time, count(b.id) as anwser_counts from questions_question a left join questions_anwser b on (a.id = b.question_id ) left join questions_question_type c on (a.type_id = c.id) %(type_filter)s group by a.id order by a.lastest_anwser_time desc ''', 1:''' select * from ( select t.*, sum(d.visits) as tag_vistis_counts from ( select a.id,a.title,a.visits,a.quest_time,c.type_name,a.lastest_anwser_time, count(b.id) as anwser_counts from questions_question a left join questions_anwser b on (a.id = b.question_id ) left join questions_question_type c on (a.type_id = c.id) %(type_filter)s group by a.id )t left join questions_question_tags b on (t.id = b.question_id ) left join questions_question_tag d on (b.question_tag_id = d.id ) group by t.id )s order by s.tag_vistis_counts ''', 2:''' select a.id,a.title,a.visits,a.quest_time,c.type_name,a.lastest_anwser_time, count(b.id) as anwser_counts from questions_question a left join questions_anwser b on (a.id = b.question_id ) left join questions_question_type c on (a.type_id = c.id) %(type_filter)s group by a.id order by a.visits desc ''', 3:''' select * from ( select a.id,a.title,a.visits,a.quest_time,c.type_name,a.lastest_anwser_time, count(b.id) as anwser_counts from questions_question a left join questions_anwser b on (a.id = b.question_id ) left join questions_question_type c on (a.type_id = c.id) %(type_filter)s group by a.id ) t order by t.anwser_counts desc ''' } if int(type) > 0 : type_filter = " where a.type_id =%s " % (type) else: type_filter = " " dynamicSql = operatorSql.get(int(sort)) % {'type_filter' : type_filter} question_list = DBUtils.executeQuerySql(dynamicSql, []); return question_list
def trends_page(request, page = 1): infomations = Information.objects.all(); #@UndefinedVariable info_list = DBUtils.divide_page(infomations,10, page) return render_to_response('trends.html',{'info_list': info_list},context_instance=RequestContext(request))
def qs_quest_page(request, page=1 ,sort=0 , type=0 ): questions = ctrls.getQuestionsDynamicSql( sort, type ) question_list = DBUtils.divide_page(questions , 10, page) return render_to_response('faqs_questions.html',{'question_list':question_list , 'sort' : sort ,'type' : type},context_instance=RequestContext(request))
def qs_recent_page(request, page = 1): questions = Question.objects.all() #@UndefinedVariable for question in questions: question.anwser_count = question.anwser_set.all().count(); question_list = DBUtils.divide_page(questions,10, page) return render_to_response('faqs_recent.html', {'question_list':question_list},context_instance=RequestContext(request))
def trends_page(request, page=1): infomations = Information.objects.all() #@UndefinedVariable info_list = DBUtils.divide_page(infomations, 10, page) return render_to_response('trends.html', {'info_list': info_list}, context_instance=RequestContext(request))