Exemple #1
0
def tomenu(): 
    try:
        menuid= request.query.get('menuid')
        channelids = request.query.get('channelids')


        flag=False
        for cid in channelids.split('_'):
            if cid != '':
                select_sql = "select count(*) from gkgp_cms_menu where parent=%s and path=%s"
                res = db.query_one(select_sql,(menuid,'/channel/gotochannel?cid='+cid))
                if res[0]>0:
                    flag=True
                    continue
                # delete_sql = "delete from gkgp_cms_menu where parent=%s and path=%s"
                # db.update(delete_sql,(menuid,'/channel/gotochannel?cid='+cid))

                insert_sql = "insert into gkgp_cms_menu (menuname,path,parent) values(%s,%s,%s)"
                cname = getchannelnamebyid(cid)
                db.update(insert_sql,(cname,'/channel/gotochannel?cid='+cid,menuid))
        if flag :
            return "exist"
        else:
            return 'ok'
    except Exception,data:
        traceback.print_exc()
        return 'error'
Exemple #2
0
def getUserByNameAndPass(username,password):
    sql = "select * from gkgp_user where username=%s and password=%s";
    try:
        return dbsetting.query_one(sql,(username,password))
    except:
        traceback.print_exc()
        return None
Exemple #3
0
def bury(itemcode):
    try:

        uid = get_cookie(UID)
        if uid is None:
            return 'noLogin'
        else:
            item = db.query_one('select t.id,t.itemcode,t.burytimes \
                  from gkgp_item t  where t.itemcode=%s',itemcode)
            if item is not None:
                digOrBuryHistory = get_cookie('DigOrBury_'+itemcode)
                if digOrBuryHistory is not None and len(digOrBuryHistory)>0:
                    if item[2] is not None:
                        return beautifulDisPlay(str(item[2]))
                    else:
                        return '0'
                else:
                    if item[2] is not None:
                        temp = item[2]+1
                        db.update('update gkgp_item set burytimes=%s where id=%s',(temp,item[0]))
                        set_cookie('DigOrBury_'+itemcode,itemcode)
                        return beautifulDisPlay(str(temp))
                    else:
                        return '0'
            else:
                return '0'
    except Exception:
        traceback.print_exc()
        return 'bury error'
Exemple #4
0
def getnotice():
    d={}
    sql = 'select id,column_value from HNSJ_SYS_CONFIG WHERE column_name=%s'
    params=('MARQUEE_NOTE')
    res = db.query_one(sql,params)
    print res
    d['note_id'] = res[0]
    d['note_value'] =res[1]
    return dict(note=d,domain=SITE_DOMAIN)
Exemple #5
0
def gotoedit():
    vid = request.query.get('id')
    sql = "select itemid,description,picurl,productid,status,title from HNSJ_TDCMS_CHANNEL_ITEM where itemid=%s"
    video = db.query_one(sql,(vid))
    print video
    #-----get product ---------
    sql = "select t1.id ,t1.item_id,t1.product_id,t.sp_productid from HNSJ_VAC_PROINFO t,HNSJ_TDCMS_ITEM_PRODUCT t1 where \
            t.sp_productid = t1.product_id and t1.id = %s"
    p = db.query_list(sql,(video[0]))


    #-----get support cpids----
    sql = "select column_value from HNSJ_SYS_CONFIG where column_name = %s"
    cpids = db.query_one(sql,('SUPPORT_CP_IDS'))[0]
    print cpids
    cpidsql = ','.join(cpids.split(','))
    print cpidsql

    #------get all product------
    sql = "select sp_productid,productname from HNSJ_VAC_PROINFO where spid in (%s)"
    allproductlist = db.query_list(sql,(cpidsql))


    return dict(v = video,domain=SITE_DOMAIN,allproductlist=allproductlist,p=p)
Exemple #6
0
def play(itemcode):
    item = db.query_one('select t1.id,t1.itemcode,t.username,t.id,t1.title,t1.addtime,t1.description,t1.playtimes,t1.digtimes,t1.burytimes \
      ,t1.pics from gkgp_user t,gkgp_item t1 ,gkgp_user_item t2 where t1.id = t2.videoid and t2.userid = t.id and \
       itemcode=%s',(itemcode))
    # put play history into cookie
    # key : playlist
    # value : {'itemcode1','itemcode3','itemcode4'}
    playlist = get_cookie('playlist')
    if playlist:
        l=json.loads(playlist)
        if itemcode not in l:
            if(len(l)>=10):
                del l[0]
                l.append(itemcode)
            else:
                l.append(itemcode)
            set_cookie('playlist',json.dumps(l))
    else:
        l=[]
        l.append(itemcode)
        set_cookie('playlist',json.dumps(l))
    # end

    if item is not None:
        playtime = 0
        if item[7] is not None and item[7]>=0:
            playtime = item[7]+1
        else:
             playtime =1
        db.update('update gkgp_item set playtimes=%s where id=%s',(playtime,item[0]))
    #首发
    firstvideo = main.changeVideo(main.findItem(8,5))
    # get user  other videos
    othervideos = db.query_list('select t.title,t.pics,t.itemcode from gkgp_item t, \
        gkgp_user_item t1 where t.id=t1.videoid and t1.userid=%s order by t.addtime desc limit 0,4 ',(item[3]))

    item = list(item)
    item[7] = beautifulDisPlay(str(item[7]))
    item[8] = beautifulDisPlay(str(item[8]))
    item[9] = beautifulDisPlay(str(item[9]))

    return dict(domain=SITE_DOMAIN,picdomain=PIC_DOMAIN,itemcode=itemcode,item=item,firstvideo=firstvideo,othervideos=othervideos)
Exemple #7
0
def delete():
    id = request.query.get('id')
    try:

        if id.index(',')!=-1:
            id = id[0:-1]
        ids = id.split(',')
        #print ids
        if 0 < len(ids):
            for i in range(len(ids)):
                item = db.query_one('select id,small_pic,big_pic from gkgp_main_setting where id =%s',ids[i])
                #print item
                if item[1] is not  None and len(item[1])>0  and os.path.exists(STATIC_PATH+item[1]):
                    os.remove(STATIC_PATH+item[1])
                if  item[2] is not None and len(item[2])>0 and os.path.exists(STATIC_PATH+item[2]):
                    os.remove(STATIC_PATH+item[2])
                db.delete('delete from gkgp_main_setting where id = %s',item[0])
            return gotoindexsetting()
    except:
        traceback.print_exc()
        return "delete index setting error"
Exemple #8
0
def getchannelnamebyid(id):
    sql = "select name from HNSJ_TDCMS_CHANNEL where id = %s"
    return db.query_one(sql,(id))[0]
Exemple #9
0
def getchannelnamebyid(id):
	sql = "select channel_name from gkgp_channel where id = %s"
	return db.query_one(sql,(id))[0]
Exemple #10
0
def gotoedit():
    ids = request.query.get('id')
    moduleid = request.query.get('moduleid')
    id=ids.split('_')[0]
    item = db.query_one('select * from gkgp_main_setting where id = %s',(id))
    return template('main/main_edit',dict(domain=SITE_DOMAIN,itemdict=itemdict,selectmodule=moduleid,moduledict=moduledict,item=item))
Exemple #11
0
def getUserByUsername(username):
    sql = "select * from gkgp_user where username=%s"
    return dbsetting.query_one(sql,username)
Exemple #12
0
def getUserByNameAndPass(username,password):
    sql = "select * from gkgp_user where username=%s and password=%s";
    return dbsetting.query_one(sql,(username,password))
Exemple #13
0
def getUserByNickname(nickname):
    sql = "select * from gkgp_user where nickname=%s"
    return dbsetting.query_one(sql,nickname)
Exemple #14
0
def getItemCountByUid(item_type,Uid):
	sql="select count(*) from gkgp_channel_item_link where item_type=%s and uid=%s"
	return db.query_one(sql,(item_type,Uid))
Exemple #15
0
def getItemCountByChannelId(item_type,chId):
	'''获取条件下视频的总条数'''
	sql = "select count(*) from gkgp_channel_item_link where item_type=%s and channel_id=%s and status=1"
	return db.query_one(sql,(item_type,chId))
Exemple #16
0
def getUserInfoById(id):
    sql = "select * from gkgp_user where id=%s"
    return dbsetting.query_one(sql,id)