def do_action(self, queryset):
     # queryset 是包含了已经选择的数据的 queryset
     for obj in queryset:
         # obj 的操作
         weixinInfoList=[]
         if obj.weixin_no is not None:
             weixinInfoList.extend(getWeixinInfoList(weixin_no=obj.weixin_no))
         if obj.openid is not None:
             weixinInfoList.extend(getWeixinInfoList(openid=obj.openid))
         if len(weixinInfoList)==0:
             weixinInfo = WeixinInfo()
             weixinInfo.weixin_name = obj.weixin_name
             weixinInfo.weixin_no = obj.weixin_no
             weixinInfo.openid = obj.openid
             weixinInfo.save()
         obj.delete()
Example #2
0
 def do_action(self, queryset):
     # queryset 是包含了已经选择的数据的 queryset
     for obj in queryset:
         # obj 的操作
         weixinInfoList = []
         if obj.weixin_no is not None:
             weixinInfoList.extend(
                 getWeixinInfoList(weixin_no=obj.weixin_no))
         if obj.openid is not None:
             weixinInfoList.extend(getWeixinInfoList(openid=obj.openid))
         if len(weixinInfoList) == 0:
             weixinInfo = WeixinInfo()
             weixinInfo.weixin_name = obj.weixin_name
             weixinInfo.weixin_no = obj.weixin_no
             weixinInfo.openid = obj.openid
             weixinInfo.save()
         obj.delete()
Example #3
0
def getWeixinInfoList(id=None, weixin_name=None, weixin_no=None, openid=None, offset=None, limit=None):
    sql = []
    sql.append("SELECT id, weixin_name, weixin_no, openid, last_scan_date, update_num, create_date FROM gather_weixininfo ")
    if id is not None:
        sql.append(" and id="+str(id))
    if weixin_name is not None:
        sql.append(" and weixin_name='"+weixin_name+"'")
    if weixin_no is not None:
        sql.append(" and weixin_no='"+weixin_no+"'")
    if openid is not None:
        sql.append(" and openid='"+openid+"'")
    if offset is not None and limit is not None:
        sql.append(" limit "+str(offset)+","+str(limit))
        
    if len(sql)>1:
        if sql[1].count("and")>0:
            sql[1] = " WHERE "+sql[1][4:]
        elif sql[1].count("limit")>0:
            pass
        else:
            print "getWeixinInfoList sql error!"
    conn = getConnect()
    cur = conn.cursor()
    cur.execute("".join(sql))
    datas = cur.fetchall()  
    weixinInfoList = []
    for data in datas:
        weixinInfo = WeixinInfo()
        weixinInfo.id = data[0]
        weixinInfo.weixin_name = data[1]
        weixinInfo.weixin_no = data[2]
        weixinInfo.openid = data[3]
        weixinInfo.last_scan_date = data[4]
        weixinInfo.update_num = data[5]
        weixinInfo.create_date = data[6]
        weixinInfoList.append(weixinInfo)
    #print weixinInfoList[0].id,weixinInfoList[0].name,weixinInfoList[0].weixin_no,weixinInfoList[0].openid,weixinInfoList[0].last_scan_date,weixinInfoList[0].update_num,weixinInfoList[0].create_date
    cur.close()
    conn.close()
    
    return weixinInfoList