Пример #1
0
def update_save(request,query):
    
    p1=oldEventToNewEvent(query,False)
    p=[]
    if p1:
        for ci in p1.city.all():
            cat_l=NewCatUrl(0,ci.title)
            for ca in p1.cat.all():
                if not cat_l.has_key(ca.id):
                    NewCatUrl(0,ci.title,True)
                     
                fid=find_cat_fid(NewCatUrl(2,ci.title),ci.id,ci.title) 
                for f in fid:
                    
                    event_city_cat(ci.id,f['id'],True)
                
        #p=[p1.id,p1.old_event.event_id,p1.old_event.event_name]
        
        NewformatEvent(p1,p1.id,True)
        msg=u'保存成功'
        p={'success':True,'msg':msg,'eid':msg}
                
    else:
        p={'msg':'err'} 
    response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")
Пример #2
0
def indexPage(request,city=None):
    cityObj = find_from_city(request,city)
    tim=2015
    www={'id':2,'name':'互联网会','img':'http://pic.huodongjia.com/html5/pic/www.png?time=%s'%tim,'url':'/%s/it/' % cityObj[2] }
    jinrong={'id':6,'name':'金融会议','img':'http://pic.huodongjia.com/html5/pic/jinrong.png?time=%s'%tim,'url':'/%s/finance/'  % cityObj[2]}
    hospity={'id':23,'name':'医疗会议','img':'http://pic.huodongjia.com/html5/pic/hospity.png?time=%s'%tim,'url':'/%s/medical/'  % cityObj[2]}
    maer={'id':93,'name':'骑马运动','img':'http://pic.huodongjia.com/html5/pic/maer.png?time=%s'%tim,'url':'/tag/?keyword=骑马运动' }
    fly={'id':94,'name':'飞行体验','img':'http://pic.huodongjia.com/html5/pic/fly.png?time=%s'%tim,'url':'/tag/?keyword=飞行体验' }
    foot={'id':76,'name':'美食烹饪','img':'http://pic.huodongjia.com/html5/pic/foot.png?time=%s'%tim,'url':'/chengdu/food/'}
    child={'id':24,'name':'亲子活动','img':'http://pic.huodongjia.com/html5/pic/child.png?time=%s'%tim,'url':'/tag/?keyword=亲子活动'}
    snow={'id':24,'name':'滑雪活动','img':'http://pic.huodongjia.com/html5/pic/snow.png?time=%s'%tim,'url':'/tag/?keyword=滑雪活动'}
    
    hot_cat=[www,jinrong,hospity,maer,fly,foot,child,snow]
    
    m_list=event_city_cat(cityObj[0])
    response = render_to_response('m_home.html',{'city':cityObj[1],
                                           'city_id':cityObj[0],
                                           'city_py':cityObj[2],
                                           'hot_cat':hot_cat,
                                           'list':m_list[:5],
                                           },
                                           context_instance=RequestContext(request))
    response.set_cookie('city_id',cityObj[0])
    response.set_cookie('city_py',cityObj[2])
    response.set_cookie('city',cityObj[1].encode('utf-8'))
    response['Cache-Control'] = 'max-age=300'
    return response    
Пример #3
0
def indexPage(request,city=None):
    cityObj = find_from_city(request,city)
    tim=2015
    www={'id':2,'name':'互联网会','img':'http://pic.huodongjia.com/html5/pic/www.png?time=%s'%tim,'url':'/%s/it/' % cityObj[2] }
    jinrong={'id':6,'name':'金融会议','img':'http://pic.huodongjia.com/html5/pic/jinrong.png?time=%s'%tim,'url':'/%s/finance/'  % cityObj[2]}
    hospity={'id':23,'name':'医疗会议','img':'http://pic.huodongjia.com/html5/pic/hospity.png?time=%s'%tim,'url':'/%s/medical/'  % cityObj[2]}
    maer={'id':93,'name':'骑马运动','img':'http://pic.huodongjia.com/html5/pic/maer.png?time=%s'%tim,'url':'/tag/?keyword=骑马运动' }
    fly={'id':94,'name':'飞行体验','img':'http://pic.huodongjia.com/html5/pic/fly.png?time=%s'%tim,'url':'/tag/?keyword=飞行体验' }
    foot={'id':76,'name':'美食烹饪','img':'http://pic.huodongjia.com/html5/pic/foot.png?time=%s'%tim,'url':'/chengdu/food/'}
    child={'id':24,'name':'亲子活动','img':'http://pic.huodongjia.com/html5/pic/child.png?time=%s'%tim,'url':'/tag/?keyword=亲子活动'}
    snow={'id':24,'name':'滑雪活动','img':'http://pic.huodongjia.com/html5/pic/snow.png?time=%s'%tim,'url':'/tag/?keyword=滑雪活动'}
    
    hot_cat=[www,jinrong,hospity,maer,fly,foot,child,snow]
    
    m_list=event_city_cat(cityObj[0])
    response = render_to_response('m_home.html',{'city':cityObj[1],
                                           'city_id':cityObj[0],
                                           'city_py':cityObj[2],
                                           'hot_cat':hot_cat,
                                           'list':m_list[:5],
                                           },
                                           context_instance=RequestContext(request))
    response.set_cookie('city_id',cityObj[0])
    response.set_cookie('city_py',cityObj[2])
    response.set_cookie('city',cityObj[1].encode('utf-8'))
    response['Cache-Control'] = 'max-age=300'
    return response    
Пример #4
0
def show_cache(request):
    name=request.GET.get('name',None) 
    p=[]
    if name:    
        #p = cache.get('%s' % (name)) 
        p=event_city_cat(101,69,True  )   
        response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")  
Пример #5
0
def event_city_cat_json(request,city_id=None,cat_id=None, new=False,cou=False):
    city_ids=city_id.split("_")
    if len(city_ids)>1:
        city_ids=tuple(city_ids)
    else:
        city_ids=city_id
        
    cat_ids=cat_id.split("_")
    if len(cat_ids)>1:
        cat_ids=tuple(cat_ids)
    else:
        cat_ids=cat_id
        
    ev=event_city_cat(city_ids , cat_ids , new , int(cou)  )
     
    response = json.dumps(ev)
    return HttpResponse(response, mimetype="application/json")
Пример #6
0
def event_city_cat_json(request,
                        city_id=None,
                        cat_id=None,
                        new=False,
                        cou=False):
    city_ids = city_id.split("_")
    if len(city_ids) > 1:
        city_ids = tuple(city_ids)
    else:
        city_ids = city_id

    cat_ids = cat_id.split("_")
    if len(cat_ids) > 1:
        cat_ids = tuple(cat_ids)
    else:
        cat_ids = cat_id

    ev = event_city_cat(city_ids, cat_ids, new, int(cou))

    response = json.dumps(ev)
    return HttpResponse(response, mimetype="application/json")
Пример #7
0
def showPage(request,query=False,template_name='m_event.html'): 
    event={}
    if query.isdigit():
        event= NewformatEvent(False,int(query),request.GET.get('new',False))        
 
    if not event.has_key('isshow'):
        return render_to_response('not.html',{'error_msg':u'没有该活动  '  })
  
    else:
        if not event['isshow'] in [1,8]:
            return render_to_response('not.html',{'error_msg':u'活动没有发布' })       

        city_t=event['district_title']
        city_n=event['district_name']
   

        qu=False
           
        for con in event['event_content']:
            if con[0]==u'常见问题':
                qu=True
                break
        if not qu:
            fid=find_cat_fid(NewCatUrl(2),event['catid'],city_t) 
            ark=False
            for f in fid:
                if f['article']:
                    for ar in f['article']:
                        if ar['name']==u'常见问题':
                            event['event_content'].append((ar['name'],ar['content'].replace('pic1.qkan.com','pic.huodongjia.com'),))
                            ark=True
                            qu=True
                            break
                if ark:
                    break


        new=False
        tran_rec_list =event_city_cat(None,event['catid'],new) 

        number=3
        
        
        l= len(tran_rec_list)-number
        if l<0:  
            b = event_city_cat(None,None,new )  
            #print b
            tran_rec_list.extend(b [:abs(l)] )
        #tran_rec_list =[]#  [formatEvent(item) for item in recommend_list[randloc:randloc+number]]

                        
                    
                
 
        body={'head':event['head'],
             'event':event,
             'list':tran_rec_list[:number],
             'city':city_n,
             'city_py':city_t,
             'navigationList':event['navigationList']}

        if event.has_key('cf'):
            body['cf']=event['cf']
        return render_to_response(template_name,body,context_instance=RequestContext(request))
Пример #8
0
def list_page(request,city=None,cat='meeting',month=None,offset=1):
    '''
    cal_flag: return list or calendar
    lead_cat: all the filtering is under this lead_cat category
    city, cat, month : filter the data by this city, category, month
    blank_page_flag: return blank page, if necessary
    '''

    #####################
    if cat == 'meeting':
        cat = 'business'
    #####################

    cal_flag = request.GET.get('cal')
    if cal_flag: cal_flag = 1

    #lead_cat = 'meeting'
    lead_cat = 'business'

    new = False
    if request.GET.get('db') and request.user.is_authenticated():
        new = True

    blank_page_flag = False

    month_int = 0
    if month:
        if month.isdigit():
            month_int = int(month)
        else:
            #return redirect(reverse('new_event.showlist.list', kwargs={'city':city, 'cat':cat}))
            raise Http404

        if int(month) not in range(1,13):
            raise Http404
            #month_int = 0
            #month = None
            #return redirect(reverse('rd_page', kwargs={'city':city, 'cat':cat}))

    #in the calendar page, no 'all' option for month selection
    if cal_flag and month_int == 0:
        raise Http404

    #if month before the current, then it means the month of next year
    today = datetime.date.today()
    if month_int == 0:
        date_in = ''
    else:
        date_in = datetime.date(today.year+1 if month_int < today.month else today.year
                            ,month_int,1)
    
    #month = str(month).zfill(2)

    #if city not in the city-dataset or != 'city', raise 404
    city_title_dict = NewCity(3)
    if not city:
        city_info = (0,u'不限','')
    elif city_title_dict.has_key(city):
        city_info = city_title_dict[city]
    else:
        raise Http404
        #blank_page_flag = True
    

    #get all cats by city
    #if cat not in the lead-cats-dataset or != lead_cat, return empty
    cat_ename_dict = NewCatUrl(0, '', new=new)
    cat_ename_list = []
    seo_dict = {}
    if cat_ename_dict.has_key(lead_cat):
#to include category itself and its children
        cat_ename_list += [cat_ename_dict[lead_cat]] + \
                filter(lambda x: x['ename'] not in ['meeting','training','expo'], 
                        cat_ename_dict[lead_cat]['child'])
        try:
            seo_dict = cat_ename_dict[cat]['seo']
        except KeyError:
            pass
    else:
        #raise Http404
        blank_page_flag = True

    cat_id = 0
    if cat not in [i['ename'] for i in cat_ename_list]:
        raise Http404
        #cat = lead_cat

    cat_id = cat_ename_dict[cat]['id']

    #get all tags by cats (how to by cities & cats)
    tag_name = request.GET.get('tag')
    #tag_name is None not in the url
    #set it to '' for the further usage
    if not tag_name:
        tag_name = ''
    else:
        tag_name.encode('utf-8')


    tag_id = 0  #default

    #get all tags under the category
    tag_name_id_dict = {}
    if cat_ename_dict.has_key(cat):
        for i in cat_ename_dict[cat]['tag']:
            if i.has_key('id') and i.has_key('name'):
                tag_name_id_dict[i['name']] = i['id']
    else:
        #blank_page_flag = True
        tag_name = ''


    if tag_name:
        if tag_name_id_dict.has_key(tag_name):
            tag_id = tag_name_id_dict[tag_name]
        else:
            #pass
            tag_name = ''
            #blank_page_flag = True

    offset_str = request.GET.get('page')
    if offset_str:
        try:
            offset = int(offset_str)
            if offset < 1:
                offset = 1
        except TypeError:
            offset = 1
    

    listDict = {}

    #BreadcrumbNavigation
    listDict['bn_title'] = ''
    if date_in:
        listDict['bn_title'] += month_int2ch(date_in.month)
    if city:
        listDict['bn_title'] += city_info[1]
    if tag_name:
        listDict['bn_title'] += tag_name
        listDict['bn_title'] += u'会议'
    else:
        if cat != lead_cat:
            listDict['bn_title'] += cat_ename_dict[cat]['catname']
        else:
            if listDict['bn_title']:
                listDict['bn_title'] += u'会议'



    ######################
    #info of current page#
    ######################
    listDict['current_city'] = city_info[1]
    #cat == '' indicates the cat_ename_dict is empty
    listDict['current_cat'] = cat_ename_dict[cat]['catname'] if cat != lead_cat and cat else u'不限'
    listDict['current_month'] = month_int2ch(month_int)
    listDict['current_tag'] = tag_name if tag_name else u'不限'

    ###############
    #advertisement#
    ###############
    ads = get_image_ads(4)
    listDict['ads'] = map(set_ads_img_url, ads)

    ###############
    #friendly link#
    ###############
    links = get_site_links(new)
    if city:
        links = filter(lambda x: city in x[4], links)
    else:
        links = filter(lambda x: not len(x[4]), links)
    if cat != lead_cat:
        links = filter(lambda x: cat in x[5], links)
    else:
        links = filter(lambda x: not len(x[5]), links)

    listDict['site_links'] = links


    ################
    #filter options#
    ################
    #do not include 'page='
    url_tail = [['tag', quote(tag_name.encode('utf-8'))], ['cal', cal_flag]]
    url_tail_for_cat = [['cal', cal_flag]]

    #nu:name,url
    listDict['city_nu'] = move_to_n_first(
            list_get_city_ch_py_url(lead_cat, cat, month, url_tail, new), 
            city_info[0], 1)

    listDict['cat_nu'] = list_get_cat_ch_py_url(
            lead_cat, cat_ename_list, city, month, url_tail_for_cat, new)

    listDict['month_nu'] = list_get_month_ch_py_url(
            lead_cat, cat, city, today.year, today.month, url_tail, new)

    listDict['tag_nu'] = move_to_n_first(
            list_get_tag_ch_py_url(lead_cat, cat, city, month, tag_name_id_dict, [['cal', cal_flag]], new),
            tag_id, 1)


    #####
    #seo#
    #####
    if city_info[0]:
        html_head_city = city_info[1]
    else:
        #html_head_city = ','.join([i[1] for i in city_title_dict.values()])
        html_head_city = u''

    if cat == lead_cat:
        html_head_cat = ','.join([i['ename'] for i in cat_ename_list])
    else:
        html_head_cat = cat_ename_dict[cat]['ename']

    if month_int:
        html_head_date = u'%s年%s月' %(date_in.year, date_in.month)
    else:
        html_head_date = u'最新'

    if tag_name and cat != lead_cat:
        #html_head_tag = ','.join(tag_name_id_dict.keys())
        html_head_tag = tag_name
    else:
        html_head_tag = ''

    listDict['head'] = get_list_cal_head(seo_dict, html_head_city, html_head_cat, html_head_date, html_head_tag, cal=cal_flag, new=new)


    ##################
    #list or calendar#
    ##################
    listDict['cal_flag'] = cal_flag

    if cal_flag:
        #remove 'all' option for month-selection in the calendar page
        listDict['month_nu'] = listDict['month_nu'][1:]

        listDict['year'] = date_in.year
        listDict['month'] = date_in.month

        u_tail = ''
        if tag_name:
            u_tail = '?tag=' + quote(tag_name.encode('utf-8'))
        listDict['switch_link'] = '/' + join_advanced([city, cat, month]) \
                                + '/' + u_tail
        listDict['calendar_table'] = calendar_page(cat, city_info, date_in, tag_id, new)
        listDict['reset_link'] = '/' + join_advanced([lead_cat, str(today.month).zfill(2)+'?cal=1'])


    else:
        if tag_name:
            u_tail = '?tag=' + quote(tag_name.encode('utf-8')) + '&cal=1'
        else:
            u_tail = '?cal=1'

        if month:
            listDict['switch_link'] = '/' + join_advanced([city, cat, month]) \
                                    + '/' + u_tail
        else:
            listDict['switch_link'] = '/' + join_advanced([city, cat, str(today.month).zfill(2)]) \
                                    + '/' + u_tail

        listDict['reset_link'] = '/' + lead_cat + '/'


        ##############
        #right column#
        ##############
        listDict['right_news'] = list_get_right_news(today, new)
        listDict['right_news_more'] = '/spot/'

        listDict['right_video'] = list_get_right_video(today, new)
        listDict['right_video_more'] = '/video/'

        listDict['right_top10'] = event_city_cat('',69)[:10]


        #do not raise 404
        if blank_page_flag:
            return render(request, 's_list.html', listDict)

        #the amount of the events


        count = get_event_list_by_ccdt(cat=cat,city=city_info,date=date_in,page=False,offset=False,order='',new=new,tag_id=tag_id)

        count=count if count else 0

        perpage=12
        pages = count/perpage
        if 0 != (count%perpage): pages = pages + 1
        if offset > pages: offset = pages
        
        listDict.update(show_list(request,city_info,cat,date_in,tag_id,perpage,offset,new))

        listDict['firstPage'],listDict['lastPage'],listDict['prePage'],listDict['nextPage'],listDict['pageList'] \
                = list_page_url(city,cat,month,tag_name,pages,offset)


    return render(request, 's_list.html', listDict)
Пример #9
0
def showPage(request,query=False,template_name='m_event.html'): 
    event={}
    if query.isdigit():
        event= NewformatEvent(False,int(query),request.GET.get('new',False))        
 
    if not event.has_key('isshow'):
        return render_to_response('not.html',{'error_msg':u'没有该活动  '  })
  
    else:
        if not event['isshow'] in [1,8]:
            return render_to_response('not.html',{'error_msg':u'活动没有发布' })       

        city_t=event['district_title']
        city_n=event['district_name']
   

        qu=False
           
        for con in event['event_content']:
            if con[0]==u'常见问题':
                qu=True
                break
        if not qu:
            fid=find_cat_fid(NewCatUrl(2),event['catid'],city_t) 
            ark=False
            for f in fid:
                if f['article']:
                    for ar in f['article']:
                        if ar['name']==u'常见问题':
                            event['event_content'].append((ar['name'],ar['content'].replace('pic1.qkan.com','pic.huodongjia.com'),))
                            ark=True
                            qu=True
                            break
                if ark:
                    break


        new=False
        tran_rec_list =event_city_cat(None,event['catid'],new) 

        number=3
        
        
        l= len(tran_rec_list)-number
        if l<0:  
            b = event_city_cat(None,None,new )  
            #print b
            tran_rec_list.extend(b [:abs(l)] )
        #tran_rec_list =[]#  [formatEvent(item) for item in recommend_list[randloc:randloc+number]]

                        
                    
                
 
        body={'head':event['head'],
             'event':event,
             'list':tran_rec_list[:number],
             'city':city_n,
             'city_py':city_t,
             'navigationList':event['navigationList']}

        if event.has_key('cf'):
            body['cf']=event['cf']
        return render_to_response(template_name,body,context_instance=RequestContext(request))
Пример #10
0
def showPage(request, query=False):
#def showPage(request,query=False,template_name='show_event.html'): 
    event={}

    if query.isdigit():
                event= NewformatEvent(False,int(query),request.GET.get('new',False))        
 
    if not event.has_key('isshow'):
        return render_to_response('base_error.html',{'error_msg':u'没有该活动  '  })
  
    else:
        if not event['isshow'] in [1,8]:
            return render_to_response('base_error.html',{'error_msg':u'活动没有发布' })       
        ##################
        #2015.1.28
        tp_prt_dir = 'zhuanti/'
        #template_name = tp_prt_dir + event['ename'] + '.html'
        #url_name = tp_prt_dir + zhuanti + '.html'
        #if template_name == url_name:
        #    try:
        #        template.loader.get_template(template_name)
        #    except template.TemplateDoesNotExist:
        #        template_name = tp_prt_dir + 'event.html'
        #else:
        #    raise Http404
        template_name = tp_prt_dir + event['ename'] + '.html'
        ################

        #city_t=event['district_title']
        #city_n=event['district_name']
        city_t = ''
        city_n = ''
   
        console_success = False
        if saveConsult(request,event['event_id'],event['event_name']) == True:
            console_success = True
            
        suggestion_success = False
        if saveSuggestion(request,event['event_id'],event['event_name']) == True:
            suggestion_success = True
        
        qu=False
        
        '''
        for i in range(len(event['event_content'])):
            if event['event_content'][i][0]==u'会议通知':
                ko=event['event_content'][i]
                del event['event_content'][i]
                event['event_content'].insert(0,ko)
                    
            if event['event_content'][i][0]==u'会议门票':
                ko=event['event_content'][i]
                del event['event_content'][i]
                event['event_content'].insert(1,ko)
        '''       
                        
        for con in event['event_content']:
            if con[0]==u'常见问题':
                qu=True
                break
        if not qu:
            fid=find_cat_fid(NewCatUrl(2),event['catid'],city_t) 
            ark=False
            for f in fid:
                if f['article']:
                    for ar in f['article']:
                        if ar['name']==u'常见问题':
                            event['event_content'].append((ar['name'],ar['content'].replace('pic1.qkan.com','pic.huodongjia.com'),))
                            ark=True
                            qu=True
                            break
                if ark:
                    break

                        
                
                 
        
        '''
        
        if cache.has_key('rec_with_cat_%s'%event['event_cat']):
            recommend_list = cache.get('rec_with_cat_%s'%event['event_cat'])
        else:
        '''
        #recommend_list = NowEvent.objects.filter(Q(event_isshow=1)|Q(event_isshow=8),event_cat=event['event_cat']).exclude(event_id = event['event_id']).exclude(event_time_expire = 2).order_by('event_begin_time')
        #randloc = randint(0,len(recommend_list)/2)
        #number = 6
        #event_city_tag
        new=False
        if event.has_key('event_tag_id'):
            tran_rec_list=event_city_tag(event['district_id'],tuple(event['event_tag_id']),new)
        else:
            
            tran_rec_list =event_city_cat(None,event['catid'],new) 
        if event['has_picture']:
            number=4
        else:
            number=6
        
        
        l= len(tran_rec_list)-number
        if l<0:  
            b = event_city_cat(None,None,new )  
            #print b
            tran_rec_list.extend(b [:abs(l)+1] )
        #tran_rec_list =[]#  [formatEvent(item) for item in recommend_list[randloc:randloc+number]]

        tran_rec_list_new=[]
        for tr in tran_rec_list:
            if tr['event_id']!=event['event_id']:
                tran_rec_list_new.append(tr)

                
          
 
        body={'head':event['head'],
             'event':event,
             'user_viewed_events':tran_rec_list_new[:number],
             'city':city_n,
             'console_success':console_success,
             'suggestion_success':suggestion_success,
             'city_py':city_t,
             'navigationList':event['navigationList']}
        
        
        
        if event.has_key('cf'):
            body['cf']=event['cf']
        
        return render_to_response(template_name,body,context_instance=RequestContext(request))
Пример #11
0
def showPage(request, query=False):
    #def showPage(request,query=False,template_name='show_event.html'):
    event = {}

    if query.isdigit():
        event = NewformatEvent(False, int(query),
                               request.GET.get('new', False))

    if not event.has_key('isshow'):
        return render_to_response('base_error.html', {'error_msg': u'没有该活动  '})

    else:
        if not event['isshow'] in [1, 8]:
            return render_to_response('base_error.html',
                                      {'error_msg': u'活动没有发布'})
        ##################
        #2015.1.28
        tp_prt_dir = 'zhuanti/'
        #template_name = tp_prt_dir + event['ename'] + '.html'
        #url_name = tp_prt_dir + zhuanti + '.html'
        #if template_name == url_name:
        #    try:
        #        template.loader.get_template(template_name)
        #    except template.TemplateDoesNotExist:
        #        template_name = tp_prt_dir + 'event.html'
        #else:
        #    raise Http404
        template_name = tp_prt_dir + event['ename'] + '.html'
        ################

        #city_t=event['district_title']
        #city_n=event['district_name']
        city_t = ''
        city_n = ''

        console_success = False
        if saveConsult(request, event['event_id'],
                       event['event_name']) == True:
            console_success = True

        suggestion_success = False
        if saveSuggestion(request, event['event_id'],
                          event['event_name']) == True:
            suggestion_success = True

        qu = False
        '''
        for i in range(len(event['event_content'])):
            if event['event_content'][i][0]==u'会议通知':
                ko=event['event_content'][i]
                del event['event_content'][i]
                event['event_content'].insert(0,ko)
                    
            if event['event_content'][i][0]==u'会议门票':
                ko=event['event_content'][i]
                del event['event_content'][i]
                event['event_content'].insert(1,ko)
        '''

        for con in event['event_content']:
            if con[0] == u'常见问题':
                qu = True
                break
        if not qu:
            fid = find_cat_fid(NewCatUrl(2), event['catid'], city_t)
            ark = False
            for f in fid:
                if f['article']:
                    for ar in f['article']:
                        if ar['name'] == u'常见问题':
                            event['event_content'].append((
                                ar['name'],
                                ar['content'].replace('pic1.qkan.com',
                                                      'pic.huodongjia.com'),
                            ))
                            ark = True
                            qu = True
                            break
                if ark:
                    break
        '''
        
        if cache.has_key('rec_with_cat_%s'%event['event_cat']):
            recommend_list = cache.get('rec_with_cat_%s'%event['event_cat'])
        else:
        '''
        #recommend_list = NowEvent.objects.filter(Q(event_isshow=1)|Q(event_isshow=8),event_cat=event['event_cat']).exclude(event_id = event['event_id']).exclude(event_time_expire = 2).order_by('event_begin_time')
        #randloc = randint(0,len(recommend_list)/2)
        #number = 6
        #event_city_tag
        new = False
        if event.has_key('event_tag_id'):
            tran_rec_list = event_city_tag(event['district_id'],
                                           tuple(event['event_tag_id']), new)
        else:

            tran_rec_list = event_city_cat(None, event['catid'], new)
        if event['has_picture']:
            number = 4
        else:
            number = 6

        l = len(tran_rec_list) - number
        if l < 0:
            b = event_city_cat(None, None, new)
            #print b
            tran_rec_list.extend(b[:abs(l) + 1])
        #tran_rec_list =[]#  [formatEvent(item) for item in recommend_list[randloc:randloc+number]]

        tran_rec_list_new = []
        for tr in tran_rec_list:
            if tr['event_id'] != event['event_id']:
                tran_rec_list_new.append(tr)

        body = {
            'head': event['head'],
            'event': event,
            'user_viewed_events': tran_rec_list_new[:number],
            'city': city_n,
            'console_success': console_success,
            'suggestion_success': suggestion_success,
            'city_py': city_t,
            'navigationList': event['navigationList']
        }

        if event.has_key('cf'):
            body['cf'] = event['cf']

        return render_to_response(template_name,
                                  body,
                                  context_instance=RequestContext(request))
Пример #12
0
def test_data(request):

    #ca=NewCatUrl(0,'',True)
    p = []
    city = NewCity(3, True)
    for k in city.keys():
        if k:
            NewCatUrl(1, k, True)

            event_city_cat(city[k][0], (19, 70), True, True)
            event_city_cat(city[k][0], 69, True, True)

            #print k
            #print cal
            #p.append(city[k][0])
            '''
            try:
                ne=NewDistrict_s.objects.get(id=city[k][0])    
                if ne.parent_id:    
                    ne.event_count=event_city_cat(city[k][0],None,True,True)
                #else:
                    #ne.event_count=10000
                #event_city_cat()
                ne.save()
            
                #p.append(event_city_cat(city[k][0],None,False,True))
            except:
                pass
            '''

    #NewCity(3,True)

    p = NewCatUrl(0, '', True)
    '''
    event_city_cat(city[k][0],74 ,True )     
    event_city_cat(city[k][0],75 ,True )    
    #return render_to_response('base_error.html',{'error_msg':left}) 
    event_city_cat(city[k][0],70 ,True )  
    event_city_cat(city[k][0],(19,69) ,True ) 
    ev=NewEventTable.objects.filter(city=99).filter(end_time__lt=datetime.datetime.now()).filter(isshow__in=(1,8))
    cat=NewCatInfo.objects.filter(neweventtable_id__in=[e.id for e in ev]) 
    cat.query.group_by = ['neweventcat_id'] 
    cat_id={}
    f_id=[]
    for ca in cat:   
        p.append(ca.neweventcat_id)      
        find_cat(ca.neweventcat , cat_arr=f_id, cat_k=cat_id)
    #p.append(cat_id)    
    
    for cit in NewCityInfo.objects.filter(newdistrict_id=99):
        for event in cit.neweventtable__set.filter(end_time__lt=datetime.datetime.now()).filter(isshow__in=(1,8)):
            p.append(event.id)
 
    url=request.META['PATH_INFO']
    if url[-1]=="/":
        url=url[:-1]
    '''
    #for k,c in ca.items():
    #p.append(k)
    #NewCatUrl(1,'',True)

    #tmps=[]

    #cat_id=cat_id_li['fun']['id']
    #find_cat_ch(NewCatUrl(2,'beijing'),cat_id,tmp=tmps)

    #p=constructNavigationUrl('beijing',23)
    #p=event_city_cat(54,70 ,True )
    #p=find_ch(70,NewCatUrl(2,'',True))
    #p=NewCatUrl(2)

    response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")
Пример #13
0
def homePage(request, city_title=False):
    #cityId = 45052
    #city_name = u'北京'
    #title = 'beijing'
    if not city_title:
        cityObj = (None, 0, '')
    else:
        cityObj = find_from_city(request, city_title)
    left = event_city_cat(cityObj[0], 69, True)
    #right=event_city_cat(cityObj[0],(19,70)  )
    #return render_to_response('base_error.html',{'error_msg':left})
    #special_dic_list  = right [:12]
    business_dic_list = left[:12]
    '''
    r= len(special_dic_list)-8
    if r<0:  
        rb = event_city_cat(cityObj[0],70  )  
        special_dic_list.extend(rb[:abs(r)] )
        
        
    l= len(business_dic_list)-8
    if l<0:  
        b = event_city_cat(cityObj[0],(19,69)  )  
        business_dic_list.extend(b[:abs(l)] )
        #return render_to_response('base_error.html',{'error_msg':b}) 
    '''
    # 获取视频,按照end_time排序,只取6个
    video = NewEventParagraph.objects.filter(
        cat_name_id=17543).order_by('-end_time')

    def setUrl(v):
        v.video_url = '/video-' + str(v.id) + '.html'
        return v

    video_list = map(setUrl, video[:7])

    #return render_to_response('base_error.html',{'error_msg':special_dic_list})

    head = {
        'title':
        u'活动家-亚洲最大的活动网聚合平台-全面、安全、快捷、方便_认准活动家官方网站',
        'keywords':
        u'活动家,网上订票,会议网,活动网,亲子活动,活动,同城活动',
        'description':
        u'活动网为您提供海量会议,公开课,会展,极限运动,当地体验,夜生活,演出折扣票,同城活动查询,特色旅游,门票预订,报名,参加活动,每日发布最新活动,发布活动请上活动家!服务热线:400-003-3879'
    }
    hot_links = get_site_hot_links()
    hot_links_new = []
    for ev in hot_links:
        try:
            if datetime.datetime.strptime(
                    ev[5], '%Y-%m-%d %H:%M:%S') < datetime.datetime.now():
                continue
        except:
            pass
        try:
            if datetime.datetime.strptime(
                    ev[4], '%Y-%m-%d %H:%M:%S') > datetime.datetime.now():
                continue
        except:
            pass
        #ev[0]='%s%s' % (ev[0],ev[5])
        hot_links_new.append(ev)

    ###########

    def judge(string):
        for c in string:
            if c.isdigit():
                return False
        return True

    meetings = NewCatUrl(0, '', True)['business']

    i = 0
    length = len(meetings['child'])
    while i < length:
        nav = meetings['child'][i]
        if not judge(nav['caturl']) or meetings['child'][i]['ename'] in [
                'meeting', 'training', 'expo'
        ]:
            del meetings['child'][i]
            #nav['caturl'] += 'del'
            length -= 1
        else:
            i += 1
    ###########

    if city_title:
        cn = cityObj[1]
        head = {'title':u'%s商务会议网_%s同城活动网_%s活动家' % (cn, cn, cn),
            'keywords':u'%s会议网,%s同城活动,%s商务活动,%s活动' % (cn, \
                cn, cn, cn),
            'description':u'找%s会议、活动,上活动家Huodongjia.com!活动家是%s最大商务活动网站,提供%s地区专业商务会议、同城活动的查询与报名服务,涵盖IT、医疗、金融财经、能源化工、农业林业等行业优质商务会议,美食体验、极限运动、亲子活动、娱乐演出等优质同城活动,在线订票,免费发布活动,全面、安全、快捷、方便,认准活动家官方网站!服务热线:400-003-3879' % \
                    (cn, cn, cn)

            }
    else:
        head = {
            'title':
            u'活动家-专业商务会议网-亚洲最大活动网站',
            'keywords':
            u'活动网,会议网,商务活动,商务会议,活动家',
            'description':
            u'找会议,上活动家Huodongjia.com!活动家是亚洲最大商务活动网站,提供专业商务会议、同城活动的查询与报名服务,涵盖IT、医疗、金融财经、能源化工、农业林业等行业优质商务会议,美食体验、极限运动、亲子活动、娱乐演出等优质同城活动,在线订票,免费发布活动,全面、安全、快捷、方便,认准活动家官方网站!服务热线:400-003-3879'
        }

    ##########
    bay = {
        'city': cityObj[1],
        'city_id': cityObj[0],
        'city_py': cityObj[2],
        'hot_links': hot_links_new[:5],
        #'special_list':special_dic_list,
        'business_list': business_dic_list,
        'video_list': video_list,
        'meeting': meetings,
        'head': head,
        'background_img': '../images/head_background/header_background.png'
    }

    links = get_site_links()

    bay['site_links'] = []
    for li in range(len(links)):
        #####
        ####
        ###
        try:
            if 0 < len(links[li][4]):
                for l in links[li][4]:
                    if l == city_title:
                        # 分类过滤,有分类信息就显示设置分类的友情链接,没有分类的同理
                        # 首页不带分类信息
                        if len(links[li][5]) == 0:
                            bay['site_links'].append(links[li])
                        break

            else:
                #pass
                #无城市信息就显示没有设置城市的友情链接
                #有城市信息就显示设置有该城市的友情链接
                if not city_title:
                    # 分类过滤,有分类信息就显示设置分类的友情链接,没有分类的同理
                    # 首页不带分类信息
                    if len(links[li][5]) == 0:
                        bay['site_links'].append(links[li])

        except IndexError:
            # 由于get_site_links内部实现改了,所以link[li][4]和link[li][5]不会引发索引越界异常了
            # 这里是不可能到达的
            bay['site_links'].append(links[li])

    #
    bay['list'] = spot.list.showList(request, False, 'all', 'latest', 1)['list'] \
                    + spot.list.showList(request, False, 'all', 'latest', 2)['list']
    for item in bay['list'][:6]:
        item['spot_name'] = item['spot_name'].replace(u'会议报告:', '')

    #
    ############
    # 读取广告
    ############

    ads_pos_1 = get_image_ads(1)
    ads_pos_2 = get_image_ads(2)
    ads_pos_3 = get_image_ads(3)

    def set_url(ia):
        try:
            ia.pic_url = ia.pic.server.name + ia.pic.urls
        except AttributeError:
            if ia.pic is not None:
                ia.pic_url = "http://pic.huodongjia.com/" + ia.pic.urls
            else:
                ia.pic_url = ""

        return ia

    ads_in_1 = map(set_url, ads_pos_1)
    ads_in_2 = map(set_url, ads_pos_2)
    ads_in_3 = map(set_url, ads_pos_3)

    bay['ads1'] = ads_in_1
    bay['ads2'] = ads_in_2
    bay['ads3'] = ads_in_3

    response = render_to_response('home.html',
                                  bay,
                                  context_instance=RequestContext(request))
    '''
    response.set_cookie('city_id',cityObj[0])
    response.set_cookie('city_py',cityObj[2])
    response.set_cookie('city',cityObj[1].encode('utf-8'))
    response['Cache-Control'] = 'max-age=300'
    '''
    return response
Пример #14
0
def homePage(request,city_title=False):
    #cityId = 45052
    #city_name = u'北京'
    #title = 'beijing'
    if not city_title:
        cityObj=(None, 0, '')
    else:
        cityObj = find_from_city(request,city_title)
    left=event_city_cat(cityObj[0], 69, True)     
    #right=event_city_cat(cityObj[0],(19,70)  )    
    #return render_to_response('base_error.html',{'error_msg':left}) 
    #special_dic_list  = right [:12]
    business_dic_list = left [:12]
    
    '''
    r= len(special_dic_list)-8
    if r<0:  
        rb = event_city_cat(cityObj[0],70  )  
        special_dic_list.extend(rb[:abs(r)] )
        
        
    l= len(business_dic_list)-8
    if l<0:  
        b = event_city_cat(cityObj[0],(19,69)  )  
        business_dic_list.extend(b[:abs(l)] )
        #return render_to_response('base_error.html',{'error_msg':b}) 
    '''
    # 获取视频,按照end_time排序,只取6个
    video = NewEventParagraph.objects.filter(cat_name_id=17543).order_by('-end_time')
    def setUrl(v):
        v.video_url = '/video-' + str(v.id) + '.html'
        return v
    video_list = map(setUrl, video[:7])

    #return render_to_response('base_error.html',{'error_msg':special_dic_list}) 


    head = {'title':u'活动家-亚洲最大的活动网聚合平台-全面、安全、快捷、方便_认准活动家官方网站' ,
            'keywords':u'活动家,网上订票,会议网,活动网,亲子活动,活动,同城活动' ,
            'description':u'活动网为您提供海量会议,公开课,会展,极限运动,当地体验,夜生活,演出折扣票,同城活动查询,特色旅游,门票预订,报名,参加活动,每日发布最新活动,发布活动请上活动家!服务热线:400-003-3879'
            }
    hot_links=get_site_hot_links()
    hot_links_new=[]
    for ev in hot_links:
        try:
            if   datetime.datetime.strptime(ev[5],'%Y-%m-%d %H:%M:%S')<datetime.datetime.now():
                continue 
        except:
            pass
        try:
            if  datetime.datetime.strptime(ev[4],'%Y-%m-%d %H:%M:%S')> datetime.datetime.now():
                continue
        except:
            pass
        #ev[0]='%s%s' % (ev[0],ev[5])
        hot_links_new.append(ev)
    
   
        
    ###########

    def judge(string):
        for c in string:
            if c.isdigit():
                return False
        return True
    
    meetings = NewCatUrl(0,'',True)['business']
    
    i = 0
    length = len(meetings['child'])
    while i < length:
        nav = meetings['child'][i]
        if not judge(nav['caturl']) or meetings['child'][i]['ename'] in ['meeting','training','expo']:
            del  meetings['child'][i]
            #nav['caturl'] += 'del'
            length -= 1
        else:
            i += 1
    ###########

    if city_title:
        cn = cityObj[1]
        head = {'title':u'%s商务会议网_%s同城活动网_%s活动家' % (cn, cn, cn),
            'keywords':u'%s会议网,%s同城活动,%s商务活动,%s活动' % (cn, \
                cn, cn, cn),
            'description':u'找%s会议、活动,上活动家Huodongjia.com!活动家是%s最大商务活动网站,提供%s地区专业商务会议、同城活动的查询与报名服务,涵盖IT、医疗、金融财经、能源化工、农业林业等行业优质商务会议,美食体验、极限运动、亲子活动、娱乐演出等优质同城活动,在线订票,免费发布活动,全面、安全、快捷、方便,认准活动家官方网站!服务热线:400-003-3879' % \
                    (cn, cn, cn)

            }
    else:
        head = {'title':u'活动家-专业商务会议网-亚洲最大活动网站' ,
            'keywords':u'活动网,会议网,商务活动,商务会议,活动家' ,
            'description':u'找会议,上活动家Huodongjia.com!活动家是亚洲最大商务活动网站,提供专业商务会议、同城活动的查询与报名服务,涵盖IT、医疗、金融财经、能源化工、农业林业等行业优质商务会议,美食体验、极限运动、亲子活动、娱乐演出等优质同城活动,在线订票,免费发布活动,全面、安全、快捷、方便,认准活动家官方网站!服务热线:400-003-3879'
            }

    ##########
    bay={'city':cityObj[1],
       'city_id':cityObj[0],
       'city_py':cityObj[2],
       'hot_links':hot_links_new[:5],
       #'special_list':special_dic_list,
       'business_list':business_dic_list,
       'video_list': video_list,
       'meeting': meetings,

       'head':head,
       'background_img':'../images/head_background/header_background.png'}
    
    links=get_site_links()
    
    bay['site_links']=[]
    for li in range(len(links)):
        #####
        ####
        ###
        try:
            if 0 < len(links[li][4]):
                for l in links[li][4]:
                    if l == city_title:
                        bay['site_links'].append(links[li])
                        break
                    
            else:
                #pass
                #无城市信息就显示没有设置城市的友情链接
                #有城市信息就显示设置有该城市的友情链接
                if not city_title:
                    bay['site_links'].append(links[li])
        except:
            #pass
            bay['site_links'].append(links[li])
    
    #
    bay['list'] = spot.list.showList(request, False, 'all', 'latest', 1)['list'] \
                    + spot.list.showList(request, False, 'all', 'latest', 2)['list']
    for item in bay['list'][:6]:
        item['spot_name'] = item['spot_name'].replace(u'会议报告:', '')
         
    #
    ############
    # 读取广告
    ############
    
    ads_pos_1 = get_image_ads(1)
    ads_pos_2 = get_image_ads(2)
    ads_pos_3 = get_image_ads(3)
    def set_url(ia):
        try:
            ia.pic_url = ia.pic.server.name + ia.pic.urls
        except AttributeError:
            if ia.pic is not None:
                ia.pic_url = "http://pic.huodongjia.com/" + ia.pic.urls
            else:
                ia.pic_url = ""

        return ia
    
    ads_in_1 = map(set_url, ads_pos_1)
    ads_in_2 = map(set_url, ads_pos_2)
    ads_in_3 = map(set_url, ads_pos_3)
    
    bay['ads1'] = ads_in_1
    bay['ads2'] = ads_in_2
    bay['ads3'] = ads_in_3
    
    response = render_to_response('home.html',bay,
                                           context_instance=RequestContext(request))
    '''
    response.set_cookie('city_id',cityObj[0])
    response.set_cookie('city_py',cityObj[2])
    response.set_cookie('city',cityObj[1].encode('utf-8'))
    response['Cache-Control'] = 'max-age=300'
    '''
    return response
Пример #15
0
def list_page(request, city=None, cat='meeting', month=None, offset=1):
    '''
    cal_flag: return list or calendar
    lead_cat: all the filtering is under this lead_cat category
    city, cat, month : filter the data by this city, category, month
    blank_page_flag: return blank page, if necessary
    '''

    #####################
    if cat == 'meeting':
        cat = 'business'
    #####################

    cal_flag = request.GET.get('cal')
    if cal_flag: cal_flag = 1

    #lead_cat = 'meeting'
    lead_cat = 'business'

    new = False
    if request.GET.get('db') and request.user.is_authenticated():
        new = True

    blank_page_flag = False

    month_int = 0
    if month:
        if month.isdigit():
            month_int = int(month)
        else:
            #return redirect(reverse('new_event.showlist.list', kwargs={'city':city, 'cat':cat}))
            raise Http404

        if int(month) not in range(1, 13):
            raise Http404
            #month_int = 0
            #month = None
            #return redirect(reverse('rd_page', kwargs={'city':city, 'cat':cat}))

    #in the calendar page, no 'all' option for month selection
    if cal_flag and month_int == 0:
        raise Http404

    #if month before the current, then it means the month of next year
    today = datetime.date.today()
    if month_int == 0:
        date_in = ''
    else:
        date_in = datetime.date(
            today.year + 1 if month_int < today.month else today.year,
            month_int, 1)

    #month = str(month).zfill(2)

    #if city not in the city-dataset or != 'city', raise 404
    city_title_dict = NewCity(3)
    if not city:
        city_info = (0, u'不限', '')
    elif city_title_dict.has_key(city):
        city_info = city_title_dict[city]
    else:
        raise Http404
        #blank_page_flag = True

    #get all cats by city
    #if cat not in the lead-cats-dataset or != lead_cat, return empty
    cat_ename_dict = NewCatUrl(0, '', new=new)
    cat_ename_list = []
    seo_dict = {}
    if cat_ename_dict.has_key(lead_cat):
        #to include category itself and its children
        cat_ename_list += [cat_ename_dict[lead_cat]] + \
                filter(lambda x: x['ename'] not in ['meeting','training','expo'],
                        cat_ename_dict[lead_cat]['child'])
        try:
            seo_dict = cat_ename_dict[cat]['seo']
        except KeyError:
            pass
    else:
        #raise Http404
        blank_page_flag = True

    cat_id = 0
    if cat not in [i['ename'] for i in cat_ename_list]:
        raise Http404
        #cat = lead_cat

    cat_id = cat_ename_dict[cat]['id']

    #get all tags by cats (how to by cities & cats)
    tag_name = request.GET.get('tag')
    #tag_name is None not in the url
    #set it to '' for the further usage
    if not tag_name:
        tag_name = ''
    else:
        tag_name.encode('utf-8')

    tag_id = 0  #default

    #get all tags under the category
    tag_name_id_dict = {}
    if cat_ename_dict.has_key(cat):
        for i in cat_ename_dict[cat]['tag']:
            if i.has_key('id') and i.has_key('name'):
                tag_name_id_dict[i['name']] = i['id']
    else:
        #blank_page_flag = True
        tag_name = ''

    if tag_name:
        if tag_name_id_dict.has_key(tag_name):
            tag_id = tag_name_id_dict[tag_name]
        else:
            #pass
            tag_name = ''
            #blank_page_flag = True

    offset_str = request.GET.get('page')
    if offset_str:
        try:
            offset = int(offset_str)
            if offset < 1:
                offset = 1
        except TypeError:
            offset = 1

    listDict = {}

    #BreadcrumbNavigation
    listDict['bn_title'] = ''
    if date_in:
        listDict['bn_title'] += month_int2ch(date_in.month)
    if city:
        listDict['bn_title'] += city_info[1]
    if tag_name:
        listDict['bn_title'] += tag_name
        listDict['bn_title'] += u'会议'
    else:
        if cat != lead_cat:
            listDict['bn_title'] += cat_ename_dict[cat]['catname']
        else:
            if listDict['bn_title']:
                listDict['bn_title'] += u'会议'

    ######################
    #info of current page#
    ######################
    listDict['current_city'] = city_info[1]
    #cat == '' indicates the cat_ename_dict is empty
    listDict['current_cat'] = cat_ename_dict[cat][
        'catname'] if cat != lead_cat and cat else u'不限'
    listDict['current_month'] = month_int2ch(month_int)
    listDict['current_tag'] = tag_name if tag_name else u'不限'

    ###############
    #advertisement#
    ###############
    ads = get_image_ads(4)
    listDict['ads'] = map(set_ads_img_url, ads)

    ###############
    #friendly link#
    ###############
    links = get_site_links(new)
    if city:
        links = filter(lambda x: city in x[4], links)
    else:
        links = filter(lambda x: not len(x[4]), links)
    if cat != lead_cat:
        links = filter(lambda x: cat in x[5], links)
    else:
        links = filter(lambda x: not len(x[5]), links)

    listDict['site_links'] = links

    ################
    #filter options#
    ################
    #do not include 'page='
    url_tail = [['tag', quote(tag_name.encode('utf-8'))], ['cal', cal_flag]]
    url_tail_for_cat = [['cal', cal_flag]]

    #nu:name,url
    listDict['city_nu'] = move_to_n_first(
        list_get_city_ch_py_url(lead_cat, cat, month, url_tail, new),
        city_info[0], 1)

    listDict['cat_nu'] = list_get_cat_ch_py_url(lead_cat, cat_ename_list, city,
                                                month, url_tail_for_cat, new)

    listDict['month_nu'] = list_get_month_ch_py_url(lead_cat, cat, city,
                                                    today.year, today.month,
                                                    url_tail, new)

    listDict['tag_nu'] = move_to_n_first(
        list_get_tag_ch_py_url(lead_cat, cat, city, month, tag_name_id_dict,
                               [['cal', cal_flag]], new), tag_id, 1)

    #####
    #seo#
    #####
    if city_info[0]:
        html_head_city = city_info[1]
    else:
        #html_head_city = ','.join([i[1] for i in city_title_dict.values()])
        html_head_city = u''

    if cat == lead_cat:
        html_head_cat = ','.join([i['ename'] for i in cat_ename_list])
    else:
        html_head_cat = cat_ename_dict[cat]['ename']

    if month_int:
        html_head_date = u'%s年%s月' % (date_in.year, date_in.month)
    else:
        html_head_date = u'最新'

    if tag_name and cat != lead_cat:
        #html_head_tag = ','.join(tag_name_id_dict.keys())
        html_head_tag = tag_name
    else:
        html_head_tag = ''

    listDict['head'] = get_list_cal_head(seo_dict,
                                         html_head_city,
                                         html_head_cat,
                                         html_head_date,
                                         html_head_tag,
                                         cal=cal_flag,
                                         new=new)

    ##################
    #list or calendar#
    ##################
    listDict['cal_flag'] = cal_flag

    if cal_flag:
        #remove 'all' option for month-selection in the calendar page
        listDict['month_nu'] = listDict['month_nu'][1:]

        listDict['year'] = date_in.year
        listDict['month'] = date_in.month

        u_tail = ''
        if tag_name:
            u_tail = '?tag=' + quote(tag_name.encode('utf-8'))
        listDict['switch_link'] = '/' + join_advanced([city, cat, month]) \
                                + '/' + u_tail
        listDict['calendar_table'] = calendar_page(cat, city_info, date_in,
                                                   tag_id, new)
        listDict['reset_link'] = '/' + join_advanced(
            [lead_cat, str(today.month).zfill(2) + '?cal=1'])

    else:
        if tag_name:
            u_tail = '?tag=' + quote(tag_name.encode('utf-8')) + '&cal=1'
        else:
            u_tail = '?cal=1'

        if month:
            listDict['switch_link'] = '/' + join_advanced([city, cat, month]) \
                                    + '/' + u_tail
        else:
            listDict['switch_link'] = '/' + join_advanced([city, cat, str(today.month).zfill(2)]) \
                                    + '/' + u_tail

        listDict['reset_link'] = '/' + lead_cat + '/'

        ##############
        #right column#
        ##############
        listDict['right_news'] = list_get_right_news(today, new)
        listDict['right_news_more'] = '/spot/'

        listDict['right_video'] = list_get_right_video(today, new)
        listDict['right_video_more'] = '/video/'

        listDict['right_top10'] = event_city_cat('', 69)[:10]

        #do not raise 404
        if blank_page_flag:
            return render(request, 's_list.html', listDict)

        #the amount of the events

        count = get_event_list_by_ccdt(cat=cat,
                                       city=city_info,
                                       date=date_in,
                                       page=False,
                                       offset=False,
                                       order='',
                                       new=new,
                                       tag_id=tag_id)

        count = count if count else 0

        perpage = 12
        pages = count / perpage
        if 0 != (count % perpage): pages = pages + 1
        if offset > pages: offset = pages

        listDict.update(
            show_list(request, city_info, cat, date_in, tag_id, perpage,
                      offset, new))

        listDict['firstPage'],listDict['lastPage'],listDict['prePage'],listDict['nextPage'],listDict['pageList'] \
                = list_page_url(city,cat,month,tag_name,pages,offset)

    return render(request, 's_list.html', listDict)
Пример #16
0
def show_video(request, video_id=None):
    var = {}
    new = False
    today = datetime.date.today()
    key_name = 'video_%s_%s_%s' %(today.year, today.month, today.day)
    video = cache.get(key_name)

    if new or not video:
        video = NewEventParagraph.objects.filter(cat_name_id=17543).order_by('-end_time')
        cache.set(key_name, video, 60*60)

    validate = URLValidator()
    var['video'] = []


    #video_id = request.GET.get('id')
    if video_id:
        try:
            video_main = [video.get(id=int(video_id))]
            video_main.extend(video.exclude(id=int(video_id))[:4])
            video = video_main
        except ObjectDoesNotExist:
            video = video[:5]
    else:
        video = video[:5]

    var['id'] = video[0].id
    var['intro'] = video[0].tag
    var['name'] = video[0].name

    var['script'] = video[0].txt
    ############################
    #add isAutoPlay=True       #
    #at the end of 'src=...'   #
    #if the video is from YouKu#
    ############################
    pattern = re.compile('(?P<src>.+src=".+youku[\.\?\=\w/]+")')
    var['script'] = re.sub(pattern, video_add_autoplay, var['script'])


    for i in video:
        img = i.img.all()[0]
        imgurl = img.server.name + img.urls
        try:
            validate(i.txt)
            var['video'].append({'id':i.id, 'name':i.name, 'url':i.txt, 
                                 'img':imgurl, 'v_flag':0})
        except ValidationError:


            var['video'].append({'id':i.id, 'name':i.name, 
                                 'url':reverse('new_event:video_detail', args=(i.id,)),
                                 'img':imgurl, 'v_flag':1,
                                 'play': 1 if i.id == var['id'] else '0'
                                 })
    
    var['business_list'] = event_city_cat('',69)[:4]
    var['video'] = sorted(var['video'], key=lambda x:x['v_flag'], reverse=True)

    var['head'] = {'title':u'%s_在线观看_活动家高清视频' %var['name'],
                   'keywords':u'%s,%s在线观看,%s高清视频' %(var['name'], var['name'], var['name']), 
                   'description':u'%s高清视频在线观看,就在【活动家www.huodongjia.com】。视频简介:%s' %(var['name'], var['intro'] if len(var['intro']) <= 100 else var['intro'][:100] + '......')
        }

    return render(request, 'show_video.html', var)
Пример #17
0
def show_video(request, video_id=None):
    var = {}
    new = False
    today = datetime.date.today()
    key_name = 'video_%s_%s_%s' % (today.year, today.month, today.day)
    video = cache.get(key_name)

    if new or not video:
        video = NewEventParagraph.objects.filter(
            cat_name_id=17543).order_by('-end_time')
        cache.set(key_name, video, 60 * 60)

    validate = URLValidator()
    var['video'] = []

    #video_id = request.GET.get('id')
    if video_id:
        try:
            video_main = [video.get(id=int(video_id))]
            video_main.extend(video.exclude(id=int(video_id))[:4])
            video = video_main
        except ObjectDoesNotExist:
            video = video[:5]
    else:
        video = video[:5]

    var['id'] = video[0].id
    var['intro'] = video[0].tag
    var['name'] = video[0].name

    var['script'] = video[0].txt
    ############################
    #add isAutoPlay=True       #
    #at the end of 'src=...'   #
    #if the video is from YouKu#
    ############################
    pattern = re.compile('(?P<src>.+src=".+youku[\.\?\=\w/]+")')
    var['script'] = re.sub(pattern, video_add_autoplay, var['script'])

    for i in video:
        img = i.img.all()[0]
        imgurl = img.server.name + img.urls
        try:
            validate(i.txt)
            var['video'].append({
                'id': i.id,
                'name': i.name,
                'url': i.txt,
                'img': imgurl,
                'v_flag': 0
            })
        except ValidationError:

            var['video'].append({
                'id':
                i.id,
                'name':
                i.name,
                'url':
                reverse('new_event:video_detail', args=(i.id, )),
                'img':
                imgurl,
                'v_flag':
                1,
                'play':
                1 if i.id == var['id'] else '0'
            })

    var['business_list'] = event_city_cat('', 69)[:4]
    var['video'] = sorted(var['video'],
                          key=lambda x: x['v_flag'],
                          reverse=True)

    var['head'] = {
        'title':
        u'%s_在线观看_活动家高清视频' % var['name'],
        'keywords':
        u'%s,%s在线观看,%s高清视频' % (var['name'], var['name'], var['name']),
        'description':
        u'%s高清视频在线观看,就在【活动家www.huodongjia.com】。视频简介:%s' %
        (var['name'], var['intro']
         if len(var['intro']) <= 100 else var['intro'][:100] + '......')
    }

    return render(request, 'show_video.html', var)
Пример #18
0
def test_data(request):
     
    #ca=NewCatUrl(0,'',True)
    p=[]
    city=NewCity(3,True)
    for k in city.keys():
        if k:
            NewCatUrl(1,k,True)
            
            event_city_cat(city[k][0],(19,70),True,True)
            event_city_cat(city[k][0],69,True,True)
                
        #print k
        #print cal
            #p.append(city[k][0])
            
            '''
            try:
                ne=NewDistrict_s.objects.get(id=city[k][0])    
                if ne.parent_id:    
                    ne.event_count=event_city_cat(city[k][0],None,True,True)
                #else:
                    #ne.event_count=10000
                #event_city_cat()
                ne.save()
            
                #p.append(event_city_cat(city[k][0],None,False,True))
            except:
                pass
            '''
            
        
    
    #NewCity(3,True)   
    
    p=NewCatUrl(0,'',True)

    
    
    
    
    '''
    event_city_cat(city[k][0],74 ,True )     
    event_city_cat(city[k][0],75 ,True )    
    #return render_to_response('base_error.html',{'error_msg':left}) 
    event_city_cat(city[k][0],70 ,True )  
    event_city_cat(city[k][0],(19,69) ,True ) 
    ev=NewEventTable.objects.filter(city=99).filter(end_time__lt=datetime.datetime.now()).filter(isshow__in=(1,8))
    cat=NewCatInfo.objects.filter(neweventtable_id__in=[e.id for e in ev]) 
    cat.query.group_by = ['neweventcat_id'] 
    cat_id={}
    f_id=[]
    for ca in cat:   
        p.append(ca.neweventcat_id)      
        find_cat(ca.neweventcat , cat_arr=f_id, cat_k=cat_id)
    #p.append(cat_id)    
    
    for cit in NewCityInfo.objects.filter(newdistrict_id=99):
        for event in cit.neweventtable__set.filter(end_time__lt=datetime.datetime.now()).filter(isshow__in=(1,8)):
            p.append(event.id)
 
    url=request.META['PATH_INFO']
    if url[-1]=="/":
        url=url[:-1]
    '''
    #for k,c in ca.items():
        #p.append(k)
        #NewCatUrl(1,'',True)
        
     
    #tmps=[]
 
    #cat_id=cat_id_li['fun']['id']
    #find_cat_ch(NewCatUrl(2,'beijing'),cat_id,tmp=tmps)
    
    #p=constructNavigationUrl('beijing',23)
    #p=event_city_cat(54,70 ,True )
    #p=find_ch(70,NewCatUrl(2,'',True))
    #p=NewCatUrl(2)    
      
    response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")