Пример #1
0
    def getInvitationNumberByPublicId(cls,idpublic,page=0, page_size=None):
        result = [];
        try:
            param = {};
            sql = """select  
                        sur_voter.id_voter,
                        sur_voter.email,
                        CONCAT(sur_voter.firstname , ' ' , sur_voter.lastname) as name,
                        count(sur_send_mail.id_send_mail) as no_send,
                        MAX(sur_send_mail.send_date) as last_create_date
                    from 
                    sur_voter LEFT JOIN sur_respondents on sur_voter.id_voter = sur_respondents.id_voter
                    LEFT OUTER JOIN sur_send_mail on (sur_respondents.id_voter = sur_send_mail.id_voter and sur_respondents.id_question_option = sur_send_mail.id_question_option)
                    where sur_respondents.id_question_option = :idpublic 
                    GROUP BY
                        sur_voter.id_voter 
                    """  ;
            param['idpublic'] = idpublic;   
            
            colunmResult = DBSession.execute(text(sql), param );
            count=  str(colunmResult.rowcount);
            
            
            if page_size:
                sql = sql + """  limit :limit """;
                param['limit'] = page_size;
            if page: 
                page = 0 if page < 0 else page;
                sql = sql + """ offset :offset """;
                param['offset'] = str(page*page_size) ; 
                
            colunmResult = DBSession.execute(text(sql), param );
            
            
            for row in colunmResult :
                if row[0]:
                    result.append({'id_voter':row[0],'email': row[1],'name': row[2],'no_send': row[3],'last_create_date': row[4]})
                else:
                    count =0;
                

            
            return True, result, count;
        except Exception as  e:
            print e;  
            return False, result, 0;#e.__str__();
Пример #2
0
 def currentSessionAuthen(cls,session):
     
     sql = """ select ( expire_date > NOW() ) as result  from sur_user_session_authen where session_value = :sessionKey limit 1 """;
     
     
     colunmResult = DBSession.execute(text(sql), {'sessionKey' : session} );
     result = -1;
     for row in colunmResult :
         result = row[0];
     
     print "result value : " + str(result);
     if (result <=0):
         return False;
     else:
         return True;
     pass;
Пример #3
0
 def updateGroupUserCreator(self):
     result = DBSession.execute('insert into tg_user_group values(:user_id,:group_id)', {'user_id': self.user_id,'group_id':4})
     DBSession.flush() ;
Пример #4
0
 def updateGroupUserVoter(self):
    
     result = DBSession.execute('insert into tg_user_group values(:user_id,:group_id)', {'user_id': self.user_id,'group_id':2})
     #DBSession.execute(s, user_id= self.user_id ).fetchall() 
     DBSession.flush() ;