Ejemplo n.º 1
0
 def questions(self):
     try:
         #import pdb;pdb.set_trace()
         questionList = Questions.select().order_by(Questions.id.desc())
         Listtemp=[]
         for item in questionList:
             length = Answers.select().where(item.id ==Answers.question).count()
             Listtemp.append([item,length])
         self.privData['QUESTIONS_LIST'] = Listtemp
         return self.display('questions-list')
     except Exception,e:
         print e
         return self.error(msg='获取问题列表信息失败!')
Ejemplo n.º 2
0
    def list(self):
        inputParams = self.getInput()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        count = config.COUNT_PER_PAGE

        questionsList = Questions.select()
        current_user = Users.get(Users.name == self.isLogin())
        if not self.isAdmin():
            questionsList = current_user.questions_owner
        questionsList = questionsList.order_by(Questions.id.desc())
        pageString = self.getPageStr(self.makeUrl('/admin/agents/list'), page, count, questionsList.count())

        self.privData['QUESTIONS_LIST'] = questionsList.paginate(page, count)
        self.privData['PAGE_STRING'] = pageString

        return self.display('questionsList')
Ejemplo n.º 3
0
    def search(self):
        inputParams = self.getInput()
        keywords = inputParams['keywords'].strip().lower() if inputParams.has_key('keywords') else ''
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        count = config.COUNT_PER_PAGE

        current_user = Users.get(Users.name == self.isLogin())
        questionsList = Questions.select().where(Questions.title.contains(keywords))
        if not self.isAdmin():
            questionsList = current_user.questions_owner
        questionsList = questionsList.order_by(Questions.id.desc())
        pageString = self.getPageStr(self.makeUrl('/admin/questions/list'), page, count, questionsList.count())

        self.privData['QUESTIONS_LIST'] = questionsList.paginate(page, count)
        self.privData['PAGE_STRING'] = pageString

        return self.display('questionsList')