Ejemplo n.º 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")
Ejemplo n.º 2
0
    def render(self, context):
        #log.debug('return nav')
        output = self.nodelist.render(context).replace('\n',
                                                       '').replace('\r', '')

        out = output.split('|')
        fl = ''
        if len(out) > 1:
            cat_n = NewCatUrl(1, out[0], False, out[1])
            try:
                if 0 == len(cat_n):
                    cat_n = NewCatUrl(1, out[0], True, out[1])
            except:
                cat_n = []

            fl = out[1]

        else:
            try:
                cat_n = NewCatUrl(1, out[0])
                if 0 == len(cat_n):
                    cat_n = NewCatUrl(1, out[0], True)
            except:
                cat_n = []
        context['Show_Nav'] = []
        for cat in cat_n:
            nav = {}
            nav['url'] = cat['caturl']
            nav['name'] = cat['catname']  #+cat['flag']
            #nav['ename']=cat['caturl']

            nav['flag'] = cat['flag']
            #if cat['flag']=='true':
            #nav['url']='#'
            context['Show_Nav'].append(nav)

        nav = {}
        nav['url'] = '/searchorder/'
        nav['name'] = u'订单查询'
        if fl == 'searchorder':
            nav['flag'] = 'true'
        else:
            nav['flag'] = 'false'
        nav['rel'] = "nofollow"
        nav['class'] = "last"
        context['Show_Nav'].append(nav)

        context['city_Nav'] = NewCity(0)

        #context['site_links']=get_site_links(True)
        context['time'] = '20150209'

        return ''
Ejemplo n.º 3
0
def ldstest(request):
    from admin_self.common import find_cat_ch
    video = list_get_right_video(datetime.date.today(), True)
    var = {}
    var['video'] = video
    return HttpResponse(json.dumps(var), content_type='application/json')
    new = True
    var = {}
    lead_cat = 'meeting'
    cat = 'finance'
    city = 'beijing'
    month = '02'
    tag_name = u'不限'.encode('utf8')

    cat_ename_dict = NewCatUrl(0, city, new=False)
    cat_ename_list = cat_ename_dict[cat]['child']
    tag_id_name_list = []
    for i in cat_ename_list:
        if i['tag']:
            tag_id_name_list.extend(i['tag'])

    tag_name_id_dict = {}
    for [id, name] in tag_id_name_list:
        tag_name_id_dict[name] = id

    cat_in = 'finance'
    city_info = (0, u'不限', '')
    date_in = datetime.date.today()
    tag_id = ''
    var['calendar_table'] = calendar_page(cat_in, city_info, date_in, tag_id,
                                          new)

    return render(request, 'ldstest.html', var)

    cat_ename_dict = NewCatUrl(0, city, new=new)
    cat_ename_list = [i['ename'] for i in cat_ename_dict[lead_cat]['child']]

    ev_tmp = NewEventTable.objects.filter(isshow__in=(1, 8)).filter(
        end_time__gte=datetime.date.today()).filter(
            cat__ename__in=cat_ename_list)
    ev = ev_tmp[0].city.all()
    return HttpResponse(json.dumps(ev[0]), content_type='application/json')
Ejemplo n.º 4
0
def list_get_city_ch_py_url(cat1_title,
                            cat2_title,
                            month,
                            url_tail,
                            new=False):
    '''
    get urls on the city links for the new list page
    '''

    #-----------------
    #2015.2.4 add 2nd parameter in city_without_level1
    #to filter the cities which doesn't hold any event under the specific categories
    cat_filter = []
    cat_ename_dict = NewCatUrl(0, '', new=new)
    for i in [cat_ename_dict[cat1_title]
              ] + cat_ename_dict[cat1_title]['child']:
        if i['ename']: cat_filter.append(i['ename'])

    #temporary
    city_ch_py = city_without_level1(new, cat_filter)

    city_ch_py_url = []

    city_pre = '/'
    city_post = join_advanced([cat2_title, month]) + '/'
    #city_post = cat2_title + '/'
    #if month:
    #    city_post += month + '/'

    #city_post = url_add_tag_page(city_post, tag)
    city_post = url_add_tail(city_post, url_tail)

    #insert 'all' at the 1st place
    city_ch_py_url.append({
        'name': u'不限',
        'title': 'city',
        'id': 0,
        'url': city_pre + city_post
    })

    for city_dict in city_ch_py:
        tmp_dict = {}
        tmp_dict['name'] = city_dict['district_name']
        tmp_dict['title'] = city_dict['title']
        tmp_dict['id'] = city_dict['id']
        tmp_dict['url'] = city_pre + tmp_dict['title'] + '/' + city_post
        city_ch_py_url.append(tmp_dict)

    return city_ch_py_url
Ejemplo n.º 5
0
def constructNavigationUrl(city, catt):

    navigationList = []

    navigationList.extend(find_cat_fid(NewCatUrl(0), catt, city))
    new_navigationList = []
    for i in range(len(navigationList)):

        if type(navigationList[i]['ename']) != long:

            new_navigationList.append(navigationList[i])

    navigationDict = dict()
    navigationDict['catname'] = u'活动网'
    navigationDict['caturl'] = '/%s/' % (city) if city else '/'
    new_navigationList.append(navigationDict)
    new_navigationList.reverse()
    return new_navigationList
Ejemplo n.º 6
0
def searchKeyword(request,offset = 15,page = 1,isTag=False):
    #mc = memcache.Client(['127.0.0.1:11211'])

    title = request.COOKIES.get('city_py', '')
    city_name = request.COOKIES.get('city', '')
    cityObj =  getCityObjFromTitle(title)
    district_id = 45052
    if cityObj:
        district_id = cityObj[0]
    if offset < 1 or page < 1:
        return render_to_response('base_error.html',{'error_msg':u'页码错误'},context_instance=RequestContext(request))
    offset = int(offset)
    page = int(page)
    error = u'你什么都没有输入'
    if request.GET.get('keyword',''):
        keyword = request.GET['keyword']
        #keyword = keyword.encode('utf8')
        #print keyword.encode('utf8')


        ##########################################
        ##if tag in tags of categories of <business>
        #### jump to new business list page
        ##########################################
        bs = NewCatUrl()['business']
        for c1 in bs['child']:
            cat = c1['ename']
            if cat in ['expo', 'meeting', 'training']:
                continue
            for tag in c1['tag']:
                if 'name' in tag and keyword in tag['name']:
                    return HttpResponseRedirect("/{cat}/?tag={tag}".format(cat=cat, \
                            tag=keyword.encode('utf-8')))
        ############################

        if keyword:
            if page == 1 and not isTag:
                        if request.META.has_key('HTTP_X_FORWARDED_FOR'):
                            ip =  request.META['HTTP_X_FORWARDED_FOR']
                        else:
                            ip = request.META['REMOTE_ADDR']
                        SysSearchKey.objects.create(keyword = keyword,
                                                    ip = ip,
                                                    search_time = time.time()
                                                    )
            if len(keyword) > 20:
                error = u'关键词的字数不能超过20'
            else:
                #events_lis = mc.get(keyword+'_search_lis')
                keyword= keyword.replace('/',' ')
                events_lis = cache.get('_'.join(keyword.split())+'_search_lis')
                if not events_lis:
                    ids = search(keyword)
                    if ids:
                        events_lis = SysEvent.objects.filter(event_id__in = ids)#.order_by('district_id='+str(district_id),'event_begin_time')
                        cache.set('_'.join(keyword.split())+'_search_lis',events_lis,300)
                if events_lis:
                    events_lis = events_lis.extra(select={'is_top':'district_id='+str(district_id)})
                    events_lis = events_lis.extra(order_by=['-is_top'])
                    #print connection.queries
                    count = events_lis.count()
                    if count%offset:
                        page_number = count/offset+1
                    else:
                        page_number = count/offset
                    rlist = [NewformatEvent(False,item.event_id) for item in events_lis[offset*(page-1):offset*page]]
                    if not isTag:
                        url = '/search/'+str(offset)+'/page/?keyword='+keyword
                    else:
                        url = '/tag/'+str(offset)+'/page/?keyword='+keyword
                    #print page_number
                    pageList = []
                    for i in range(1,page_number+1):
                        curPageFlg = False
                        if page == i:
                            curPageFlg = True
                        pageDict = {'page':i, 'pageurl':url.replace('page',str(i)),'flag':curPageFlg}
                        pageList.append(pageDict)
                        
                    if page <= 1:
                        firstPage = False
                        prePage = False
                    else:
                        firstPage = pageList[0]
                        prePage = pageList[page-2]
                        
                    if page >= page_number:
                        lastPage = False
                        nextPage = False
                    else:
                        lastPage = pageList[page_number-1]
                        nextPage = pageList[page]
                    #print pageList
                    
                    head = {'title':u'%s相关热门会议查询与报名_活动家'%(keyword),
              'keywords':u'%s相关会议,%s学术会议,%s工作会议' % \
                      (keyword, keyword, keyword),
             'description':u'找%s方面相关会议信息,就上【活动家www.huodongjia.com】。活动家为您提供全面及时的%s方面的会议、峰会、论坛、年会介绍和查询报名服务,是上万主办方推崇的%s方面会议网站。学习提升,积累人脉,精准标签,个性定制,活动家服务热线:400-003-3879。' % (keyword, keyword, keyword)}
                    return render_to_response('search_results.html',{'list':rlist,
                                                                     'city':city_name,
                                                                     'city_py':title,
                                                                     'keyword':keyword,
                                                                     'firstPage':firstPage,
                                                                     'prePage':prePage,
                                                                     'currentPage':page,
                                                                     'nextPage':nextPage,
                                                                     'lastPage':lastPage,
                                                                     'pageList':pageList,
                                                                     'head':head})
                else:
                    error = u'没能搜索到与"%s"相关的活动,你可以尝试其他搜索'%keyword
                    
                    clist = []
                    for i in [20,21,22,23,89,90]:
                        cl = cache.get('rec_with_cat_%s'%i)
                        if cl:
                            for j in cl:
                                if not random.randint(0,8):
                                    clist.append(j)
                    rlist = [formatEvent(item) for item in clist]
                    
                    if clist:
                        message = u'你可能感兴趣的活动'
                    else:
                        message = ''
                    return render_to_response('search_results.html',{'error_msg':error,'message':message,'city':city_name,'city_py':title,'list':rlist},context_instance=RequestContext(request))

        else:
            error = u'输入不能为空'

    
    return render_to_response('search_results.html',{'error_msg':error,'city':city_name,'city_py':title},context_instance=RequestContext(request))
Ejemplo n.º 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))
Ejemplo n.º 8
0
def list(request,city=None,cat=None,date=None,offset=1):
    
    
    #log.debug('get list')
              
    date = request.GET.get('dat')
    offset = request.GET.get('page')
    ''' 
    if not date and not cat:    
        return homePage(request,city)
        #return False
    '''
    ##router to homePage when host/<city> requested
    if not cat and city:
        #if city is a real <city> identifier
        titleDict = NewCity(3)
        if city in titleDict:
            return homePage(request, city)
        #else do nothing
    

    ##if <cat> in meeting -> views.list_page
    cat_url = NewCatUrl()
    meetings = cat_url['meeting']
    business = cat_url['business']
    
    tags_set = ['meeting', 'business']

    for nav in meetings['child']:
        tags_set.append(nav['ename'])
    for nav in business['child']:
        tags_set.append(nav['ename'])
        for nav2 in nav['child']:
            tags_set.append(nav2['ename'])

    #when url is host/<cat> the variable 'city' is <cat>
    if city in tags_set:
        return list_page(request, cat = city)
    if cat in tags_set:
        return list_page(request, city = city, cat = cat)
    ###

    if cat_url.has_key(city):
        cat=city
        city='';
    if not cat: cat = 'all'
    if not date: date = 'latest'
    if not offset: 
        offset = 1 
    else: 
        offset = int(offset)
 
    
    
    listDict = showList(request,city,cat,date,offset)
    
    
    links=get_site_links()
    
    site_link_city=[]
    for li in range(len(links)):
        try:
            if 0 < len(links[li][4]):
                for l in links[li][4]:
                    if l == city:                         
                        site_link_city.append(links[li])
                        break
                    
            else:
                pass
                #listDict['site_links'].append(links[li])
        except:
            pass
            #listDict['site_links'].append(links[li])
    
    site_link_cat=[]
    for li in range(len(site_link_city)):
        try:
            if 0 < len(site_link_city[li][5]):
                for l in site_link_city[li][5]:
                    if str(l) == str(cat):                         
                        site_link_cat.append(site_link_city[li])
                        break
                    
            else:
                pass
                #site_link_cat.append(listDict['site_links'][li])
        except:
            pass
            #site_link_cat.append(listDict['site_links'][li])  
    listDict['site_links']=site_link_cat
    
    #print connection.queries
    return render_to_response('list.html',listDict,context_instance=RequestContext(request))
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
def showList(request,city, cat, date, offset):
    #translate city character to city digit
    #log.debug('get showlist')
    cityObj = NewCity(3)
    if cityObj.has_key(city):
        ci=cityObj[city]
    else:
        ci=(0,'','')#cityObj['beijing']

    cityId = ci[0]
 
    cityName = ci[1]
    cityPy = ci[2]
     
    
    #get sql query condition
    perpage=10
    offset = int(offset)
    cout = perpage*(offset-1)
    try:
        url=request.META['PATH_INFO']
        if url[-1]=="/":
            url=url[:-1] 
    except:
        url=''
    
    count =   get_event_list( cat,ci,date ,False,False,False)      
    
    count=count if count else 0
    pages = count/perpage
    if 0 != (count%perpage):
        pages = pages + 1
    
    orderStr = 'end_time'

    if 'new' == date:
        orderStr = '-rel_time'
        
    mlist =  get_event_list( cat,ci,date, cout,cout+perpage,orderStr)
    tmp = []
    if mlist:
        print mlist
        for item in mlist:
            tmp.append(NewformatEvent(False,item))
    
    #list page: dat url,cat url,navigation url,slice page url
    #datList = constructDatUrl(city,cat,date)
    #constructCatUrl(city,cat,date)
    #catUrlLv1 = constructCatUrl(city,cat,date)
    
    navigationList =constructNavigationUrl ( cityPy,cat)
    
 
            
    ''' 
    i=len(navigationList)
    nv=[]
    #import copy 
    catss= NewCatUrl(2)
    for k in range(i):
        
        if k==3:
            break
        nv.append(navigationList[i-1-k])
    cstr=[] 
    le=len(nv)
    for kh in range(le):        
        if nv[le-1-kh].has_key('id'):
            cat_k=[]      
            for ch in catss[nv[le-1-kh]['id']]['child']:
                for n in nv:
                    if n.has_key('id'):
                        if ch['id']==n['id']:
                            ch['flag'] = 'true'
                
                if ch['ename']:
                    cat_k.append(ch)
            cstr.append(cat_k)
        
            
 
    
    le= len(nv)   
    cat_k={}
    for ki in range(le):
        
        cstr='c%s' % ki
        cat_k[cstr]=[]
        if nv[le-1-ki]
        for ch in catss[nv[le-1-ki]['id']]['child']:
            cat_k[cstr].append(ch)
            
    '''
            
            
         
            
        
        
    
    
    firstPage,lastPage,prePage,nextPage,pageList = constructSliceUrl(city,cat,date,pages,offset)
    
    head = getListHeadNew(ci,cat,date)
    if offset>1:

        head['title']=u'%s[第%s页]' % (head['title'],str(offset))

    #head = getListHead(cityName,cat,date)
    datList = constructDatUrl(city,cat, date)
    listDict = {'city':cityName,
                'city_py':cityPy,
                 'list':tmp,
                 'datList':datList,
                 'catUrlLv1':NewCatUrl(1,cityPy,False,cat),
                 'allcat':'/'+cityPy+'/all/' if cityPy else '/',
                 'navigationList':navigationList,
                 'firstPage':firstPage,
                 'lastPage':lastPage,
                 'prePage':prePage,
                 'nextPage':nextPage,
                 'countpage':pages,
                 'pageList':pageList,
                 'head':head,
                 'cat':cat,
                 'cat_k':mlist
                               }
    return listDict
Ejemplo n.º 11
0
def list_page(request, city='city', 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
    '''

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

    lead_cat = 'meeting'

    if request.GET.get('db'):
        new = True
    else:
        new = False

    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 month_int not in range(0, 13):
        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 city == '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]
                           ] + 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]:
        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 = ''

    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

    ######################
    #info of current page#
    ######################
    listDict = {}

    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'不限'

    #do not include 'page='
    url_tail = [['tag', tag_name], ['cal', cal_flag]]
    url_tail_for_cat = [['cal', cal_flag]]

    ################
    #filter options#
    ################
    #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)

    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/'

    ##################
    #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
        #listDict['switch_link'] = '/' + '/'.join([lead_cat, city, cat, month, '?tag='+ tag_name])
        listDict['switch_link'] = '/' + '/'.join(
            [city, cat, month, '?tag=' + tag_name])
        listDict['calendar_table'] = calendar_page(cat, city_info, date_in,
                                                   tag_id, new)
        #listDict['reset_link'] = '/' + '/'.join([lead_cat, 'city', lead_cat, str(today.month).zfill(2)]) + '?cal=1'
        listDict['reset_link'] = '/' + '/'.join(
            ['city', lead_cat, str(today.month).zfill(2)]) + '?cal=1'

    else:
        if month:
            #listDict['switch_link'] = '/' + '/'.join([lead_cat, city, cat, month, '?tag='+ tag_name + '&cal=1'])
            listDict['switch_link'] = '/' + '/'.join(
                [city, cat, month, '?tag=' + tag_name + '&cal=1'])
        else:
            listDict['switch_link'] = '/' + '/'.join([
                city, cat,
                str(today.month).zfill(2), '?tag=' + tag_name + '&cal=1'
            ])

        #listDict['reset_link'] = '/' + '/'.join([lead_cat, 'city', lead_cat, '00'])
        listDict['reset_link'] = '/' + '/'.join(['city', lead_cat, '00'])

        #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='')

        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)

    #####
    #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())
    else:
        html_head_tag = ''

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

    return render(request, 's_list.html', listDict)
Ejemplo n.º 12
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))
Ejemplo n.º 13
0
def getListHead(city ,cat ,date):
    city_name=city[1]
    cat_id_li=NewCatUrl(False,city[2])
    
    try:
        catEname=cat_id_li[cat]['ename']
    except:
        catEname=''
    
    head = dict()
    if date == 'thisweek':
        if 'meeting' == catEname:
            head = {'title':u'%s近期会议_活动家'%(city_name),
                 'keywords':u'%s近期会议,%s近期论坛'%(city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'%city_name
                 }
        elif 'concert' == catEname:
            head = {'title':u'%s近期演唱会_活动家'%(city_name),
                 'keywords':u'%s近期演唱会'%(city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区演唱会活动查询、门票购买服务。服务热线:400-003-3879'%city_name
                 }
        elif 'music' == catEname:
            head = {'title':u'%s近期音乐会_活动家'%(city_name),
                 'keywords':u'%s近期音乐会'%(city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区音乐会活动查询、门票购买服务。服务热线:400-003-3879'%city_name
                 }
        elif 'drama' == catEname:
            head = {'title':u'%s近期话剧_活动家'%(city_name),
                 'keywords':u'%s近期话剧'%(city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区话剧活动查询、门票购买服务。服务热线:400-003-3879'%city_name
                 }
        elif 'expo' == catEname:
            head = {'title':u'%s近期会展_%s近期展会_活动家'%(city_name,city_name),
                 'keywords':u'%s近期会展,%s近期展会'%(city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区会展,展会查询、场地预订服务。服务热线:400-003-3879'%city_name
                 }
        elif 'training' == catEname:
            head = {'title':u'%s近期培训_%s近期公开课_活动家'%(city_name,city_name),
                 'keywords':u'%s近期培训,%s近期公开课'%(city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区会展,展会查询、场地预订服务。服务热线:400-003-3879'%city_name
                 }
        else:
            head = {'title':u'%s近期活动_活动家'%(city_name),
                 'keywords':u'%s近期活动,%s近期会议,%s近期公开课,%s近期培训,%s近期会展,%s近期展会'%(city_name,city_name,city_name,city_name,city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'%city_name
                 }
    elif date == 'nextweek':
        head = {'title':u'%s最近活动_活动家'%(city_name),
                 'keywords':u'%s最近活动,%s最近会议,%s最近公开课,%s最近培训,%s最近会展,%s最近展会'%(city_name,city_name,city_name,city_name,city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'%city_name
                 }
    elif date == 'nextmonth':
        today = datetime.date.today()
        nextmonth = today + relativedelta(months=1)
        datlist = str(nextmonth).split('-')
        year = datlist[0]
        month = datlist[1]
        dt = u"%s年%s月"%(year,month)
        head = {'title':u'%s%s活动_活动家'%(city_name,dt),
                 'keywords':u'%s%s活动,%s%s会议,%s%s公开课,%s%s培训,%s%s会展,%s%s展会'%(dt,city_name,dt,city_name,dt,city_name,dt,city_name,dt,city_name,dt,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'%city_name
                 }
    elif date == 'new':
        head = {'title':u'%s最新活动_活动家'%(city_name),
                 'keywords':u'%s最新会议,%s最新公开课,%s最新培训,%s最新会展,%s最新展会'%(city_name,city_name,city_name,city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'%city_name
                 }
    else:
        pass
    
    if 0 != len(head):
        return head
    
    if catEname == 'business':
        head = {'title':u'%s会议网,会展网,%s展览会,活动家商务会议频道'%(city_name,city_name),
                 'keywords':u'%s会议,%s峰会,%s公开课,%s培训,%s会展,%s展会'%(city_name,city_name,city_name,city_name,city_name,city_name),
                 'description':u'活动家(www.huodongjia.com)商务会议频道为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'%city_name
                 }
        
    elif catEname == 'fun':
        head = {'title':u'%s演唱会,%s演出折扣票,%s同城活动,%s娱乐活动,活动家娱乐演出频道'%(city_name,city_name,city_name,city_name),
                 'keywords':u'%s演唱会、音乐会、话剧、儿童亲子、戏曲综艺、舞蹈 、小型现场、同城活动、周末活动'%city_name,
                 'description':u'活动家(www.huodongjia.com)娱乐演出频道为您提供%s地区文娱演出和其他娱乐活动查询、订票。海量活动,随时随地购票!服务热线:400-003-3879'%city_name
                 }
    else:
        head_list=None
        try:
            if cat.isdigit():
                cat=int(cat)
            if cat_id_li.has_key( cat ):
                if cat_id_li[cat]['seo']:
                    head_list = cat_id_li[cat]['seo']
                    
                    if not head_list:
                        return {'title':u'会议网_活动网_公开课培训_%s展会_活动家'%city_name,
                                 'keywords':u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议'%(city_name,city_name,city_name,city_name),
                                 'description':u'活动家网www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
                                 }
            
            #cat_seo = SysEventCat.objects.get(cat_ename = catEname).cat_seo
        except:
            return {'title':u'会议网_活动网_公开课培训_%s展会_活动家'%city_name,
                 'keywords':u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议'%(city_name,city_name,city_name,city_name),
                 'description':u'活动家网www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
                 }
        
        #head_list = cat_seo.split('[|]')
        if  head_list:
            if head_list.has_key('title'):
                head_list['title']=head_list['title'].replace('XX',city_name).replace(u'大活动',u'活动家') 
            else:
                head_list['title']=u'会议网_活动网_公开课培训_%s展会_活动家'%city_name
            
            if head_list.has_key('keywords'):
                head_list['keywords']=head_list['keywords'].replace('XX',city_name).replace(u'大活动',u'活动家')
            else:
                head_list['keywords']=u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议'%(city_name,city_name,city_name,city_name)
            
            if head_list.has_key('description'):
            
                head_list['description']=head_list['description'].replace('XX',city_name).replace(u'大活动',u'活动家')
            else:
                head_list['description']=u'活动家www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
            head =head_list
                   
        else:
            head = {'title':u'会议网_活动网_公开课培训_%s展会_活动家'%city_name,
                 'keywords':u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议'%(city_name,city_name,city_name,city_name),
                 'description':u'活动家www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
                 }
    return head
Ejemplo n.º 14
0
def getListHead(city, cat, date):
    city_name = city[1]
    cat_id_li = NewCatUrl(False, city[2])

    try:
        catEname = cat_id_li[cat]['ename']
    except:
        catEname = ''

    head = dict()
    if date == 'thisweek':
        if 'meeting' == catEname:
            head = {
                'title':
                u'%s近期会议_活动家' % (city_name),
                'keywords':
                u'%s近期会议,%s近期论坛' % (city_name, city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'
                % city_name
            }
        elif 'concert' == catEname:
            head = {
                'title':
                u'%s近期演唱会_活动家' % (city_name),
                'keywords':
                u'%s近期演唱会' % (city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区演唱会活动查询、门票购买服务。服务热线:400-003-3879'
                % city_name
            }
        elif 'music' == catEname:
            head = {
                'title':
                u'%s近期音乐会_活动家' % (city_name),
                'keywords':
                u'%s近期音乐会' % (city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区音乐会活动查询、门票购买服务。服务热线:400-003-3879'
                % city_name
            }
        elif 'drama' == catEname:
            head = {
                'title':
                u'%s近期话剧_活动家' % (city_name),
                'keywords':
                u'%s近期话剧' % (city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区话剧活动查询、门票购买服务。服务热线:400-003-3879'
                % city_name
            }
        elif 'expo' == catEname:
            head = {
                'title':
                u'%s近期会展_%s近期展会_活动家' % (city_name, city_name),
                'keywords':
                u'%s近期会展,%s近期展会' % (city_name, city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区会展,展会查询、场地预订服务。服务热线:400-003-3879'
                % city_name
            }
        elif 'training' == catEname:
            head = {
                'title':
                u'%s近期培训_%s近期公开课_活动家' % (city_name, city_name),
                'keywords':
                u'%s近期培训,%s近期公开课' % (city_name, city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区会展,展会查询、场地预订服务。服务热线:400-003-3879'
                % city_name
            }
        else:
            head = {
                'title':
                u'%s近期活动_活动家' % (city_name),
                'keywords':
                u'%s近期活动,%s近期会议,%s近期公开课,%s近期培训,%s近期会展,%s近期展会' %
                (city_name, city_name, city_name, city_name, city_name,
                 city_name),
                'description':
                u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'
                % city_name
            }
    elif date == 'nextweek':
        head = {
            'title':
            u'%s最近活动_活动家' % (city_name),
            'keywords':
            u'%s最近活动,%s最近会议,%s最近公开课,%s最近培训,%s最近会展,%s最近展会' %
            (city_name, city_name, city_name, city_name, city_name, city_name),
            'description':
            u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'
            % city_name
        }
    elif date == 'nextmonth':
        today = datetime.date.today()
        nextmonth = today + relativedelta(months=1)
        datlist = str(nextmonth).split('-')
        year = datlist[0]
        month = datlist[1]
        dt = u"%s年%s月" % (year, month)
        head = {
            'title':
            u'%s%s活动_活动家' % (city_name, dt),
            'keywords':
            u'%s%s活动,%s%s会议,%s%s公开课,%s%s培训,%s%s会展,%s%s展会' %
            (dt, city_name, dt, city_name, dt, city_name, dt, city_name, dt,
             city_name, dt, city_name),
            'description':
            u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'
            % city_name
        }
    elif date == 'new':
        head = {
            'title':
            u'%s最新活动_活动家' % (city_name),
            'keywords':
            u'%s最新会议,%s最新公开课,%s最新培训,%s最新会展,%s最新展会' %
            (city_name, city_name, city_name, city_name, city_name),
            'description':
            u'活动家(www.huodongjia.com)为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'
            % city_name
        }
    else:
        pass

    if 0 != len(head):
        return head

    if catEname == 'business':
        head = {
            'title':
            u'%s会议网,会展网,%s展览会,活动家商务会议频道' % (city_name, city_name),
            'keywords':
            u'%s会议,%s峰会,%s公开课,%s培训,%s会展,%s展会' %
            (city_name, city_name, city_name, city_name, city_name, city_name),
            'description':
            u'活动家(www.huodongjia.com)商务会议频道为您提供%s地区高大上会议,峰会,公开课,培训,会展,展会等商务活动查询、报名。学习提升,积累人脉,精准标签,个性定制。服务热线:400-003-3879'
            % city_name
        }

    elif catEname == 'fun':
        head = {
            'title':
            u'%s演唱会,%s演出折扣票,%s同城活动,%s娱乐活动,活动家娱乐演出频道' %
            (city_name, city_name, city_name, city_name),
            'keywords':
            u'%s演唱会、音乐会、话剧、儿童亲子、戏曲综艺、舞蹈 、小型现场、同城活动、周末活动' % city_name,
            'description':
            u'活动家(www.huodongjia.com)娱乐演出频道为您提供%s地区文娱演出和其他娱乐活动查询、订票。海量活动,随时随地购票!服务热线:400-003-3879'
            % city_name
        }
    else:
        head_list = None
        try:
            if cat.isdigit():
                cat = int(cat)
            if cat_id_li.has_key(cat):
                if cat_id_li[cat]['seo']:
                    head_list = cat_id_li[cat]['seo']

                    if not head_list:
                        return {
                            'title':
                            u'会议网_活动网_公开课培训_%s展会_活动家' % city_name,
                            'keywords':
                            u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议' %
                            (city_name, city_name, city_name, city_name),
                            'description':
                            u'活动家网www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
                        }

            #cat_seo = SysEventCat.objects.get(cat_ename = catEname).cat_seo
        except:
            return {
                'title':
                u'会议网_活动网_公开课培训_%s展会_活动家' % city_name,
                'keywords':
                u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议' %
                (city_name, city_name, city_name, city_name),
                'description':
                u'活动家网www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
            }

        #head_list = cat_seo.split('[|]')
        if head_list:
            if head_list.has_key('title'):
                head_list['title'] = head_list['title'].replace(
                    'XX', city_name).replace(u'大活动', u'活动家')
            else:
                head_list['title'] = u'会议网_活动网_公开课培训_%s展会_活动家' % city_name

            if head_list.has_key('keywords'):
                head_list['keywords'] = head_list['keywords'].replace(
                    'XX', city_name).replace(u'大活动', u'活动家')
            else:
                head_list[
                    'keywords'] = u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议' % (
                        city_name, city_name, city_name, city_name)

            if head_list.has_key('description'):

                head_list['description'] = head_list['description'].replace(
                    'XX', city_name).replace(u'大活动', u'活动家')
            else:
                head_list[
                    'description'] = u'活动家www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
            head = head_list

        else:
            head = {
                'title':
                u'会议网_活动网_公开课培训_%s展会_活动家' % city_name,
                'keywords':
                u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议' %
                (city_name, city_name, city_name, city_name),
                'description':
                u'活动家www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
            }
    return head
Ejemplo n.º 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)
Ejemplo n.º 16
0
def getListHeadNew(city, cat, date):
    city_name = city[1]
    cat_id_li = NewCatUrl(False, city[2])
    if cat.isdigit():
        cat = int(cat)

    data_str = ''
    if 'thisweek' == date:
        startTime = datetime.date.today() + relativedelta(weekday=MO(-1))
        #next week monday
        endTime = datetime.date.today() + relativedelta(days=+1, weekday=MO)

        data_str = u'%s年%s月%s-%s日' % (startTime.year, startTime.month,
                                      startTime.day, endTime.day)
        #data_str=datetime.datetime.strftime(startTime,'%Y年%m月%d')
        #data_str+=datetime.datetime.strftime(endTime,'-%d')
        #data_str+=u"日"
    elif 'nextweek' == date:
        #next week monday
        startTime = datetime.date.today() + relativedelta(days=+1, weekday=MO)
        #after next week monday
        endTime = startTime + relativedelta(days=+1, weekday=MO)
        #next week SUNDAY
        #endTime = today+relativedelta(days=+7,weekday=SU)datetime
        datetime.date.year
        data_str = u'%s年%s月%s-%s日' % (startTime.year, startTime.month,
                                      startTime.day, endTime.day)
        #data_str=datetime.datetime.strftime(startTime,'%Y年%m月%d')
        #data_str+=datetime.datetime.strftime(endTime,'-%d')
        #data_str+=u"日"
    elif 'nextmonth' == date:
        thisMonthStart = datetime.datetime.now().strftime('%Y-%m-1')
        tmp = thisMonthStart.split('-')
        thisMonthStart = datetime.datetime(int(tmp[0]), int(tmp[1]),
                                           int(tmp[2]))
        startTime = thisMonthStart + relativedelta(months=+1)
        endTime = thisMonthStart + relativedelta(months=+2)
        data_str = u'%s年%s月' % (startTime.year, startTime.month)
        #data_str=datetime.datetime.strftime(startTime,'%Y年%m月')

    elif date == 'new':
        data_str = u'最新'

    head_list = {}
    if cat_id_li.has_key(cat):
        catname = cat_id_li[cat]['catname']
        if cat_id_li[cat]['seo']:
            head_list = cat_id_li[cat]['seo']
    else:
        catname = ''
        head_list = None

    if head_list:
        if head_list.has_key('title'):
            head_list['title'] = head_list['title'].replace('XX',
                                                            city_name).replace(
                                                                u'大活动', u'活动家')
            head_list['title'] = head_list['title'].replace(
                '(city)', city_name)
            head_list['title'] = head_list['title'].replace('(date)', data_str)
            head_list['title'] = head_list['title'].replace('(cat)', catname)
        else:
            head_list['title'] = u'会议网_活动网_公开课培训_%s展会_活动家' % city_name

        if head_list.has_key('keywords'):
            head_list['keywords'] = head_list['keywords'].replace(
                'XX', city_name).replace(u'大活动', u'活动家')
            head_list['keywords'] = head_list['keywords'].replace(
                '(city)', city_name)
            head_list['keywords'] = head_list['keywords'].replace(
                '(date)', data_str)
            head_list['keywords'] = head_list['keywords'].replace(
                '(cat)', catname)
        else:
            head_list[
                'keywords'] = u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议' % (
                    city_name, city_name, city_name, city_name)

        if head_list.has_key('description'):

            head_list['description'] = head_list['description'].replace(
                'XX', city_name).replace(u'大活动', u'活动家')
            head_list['description'] = head_list['description'].replace(
                '(city)', city_name)
            head_list['description'] = head_list['description'].replace(
                '(date)', data_str)
            head_list['description'] = head_list['description'].replace(
                '(cat)', catname)
        else:
            head_list[
                'description'] = u'活动家www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
        head = head_list
    else:
        head = getListHead(city, cat, date)

    return head
Ejemplo n.º 17
0
def list(request, city=None, cat=None, date=None, offset=1):

    #log.debug('get list')

    date = request.GET.get('dat')
    offset = request.GET.get('page')
    ''' 
    if not date and not cat:    
        return homePage(request,city)
        #return False
    '''
    ##router to homePage when host/<city> requested
    if not cat and city:
        #if city is a real <city> identifier
        titleDict = NewCity(3)
        if city in titleDict:
            return homePage(request, city)
        #else do nothing

    ##if <cat> in meeting -> views.list_page
    cat_url = NewCatUrl()
    meetings = cat_url['meeting']
    business = cat_url['business']

    tags_set = ['meeting', 'business']

    for nav in meetings['child']:
        tags_set.append(nav['ename'])
    for nav in business['child']:
        tags_set.append(nav['ename'])
        for nav2 in nav['child']:
            tags_set.append(nav2['ename'])

    #when url is host/<cat> the variable 'city' is <cat>
    if city in tags_set:
        return list_page(request, cat=city)
    if cat in tags_set:
        return list_page(request, city=city, cat=cat)
    ###

    if cat_url.has_key(city):
        cat = city
        city = ''
    if not cat: cat = 'all'
    if not date: date = 'latest'
    if not offset:
        offset = 1
    else:
        offset = int(offset)

    listDict = showList(request, city, cat, date, offset)

    links = get_site_links()

    site_link_city = []
    for li in range(len(links)):
        try:
            if 0 < len(links[li][4]):
                for l in links[li][4]:
                    if l == city:
                        site_link_city.append(links[li])
                        break

            else:
                pass
                #listDict['site_links'].append(links[li])
        except:
            pass
            #listDict['site_links'].append(links[li])

    site_link_cat = []
    for li in range(len(site_link_city)):
        try:
            if 0 < len(site_link_city[li][5]):
                for l in site_link_city[li][5]:
                    if str(l) == str(cat):
                        site_link_cat.append(site_link_city[li])
                        break

            else:
                pass
                #site_link_cat.append(listDict['site_links'][li])
        except:
            pass
            #site_link_cat.append(listDict['site_links'][li])
    listDict['site_links'] = site_link_cat

    #print connection.queries
    return render_to_response('list.html',
                              listDict,
                              context_instance=RequestContext(request))
Ejemplo n.º 18
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
Ejemplo n.º 19
0
def list(request,city=None,cat=None,date=None,offset=1):
    
    date = request.GET.get('dat')
    offset = request.GET.get('page')
        
    if not date and not cat:    
        return indexPage(request,city)
        #return False


    

    if not city: city='beijing'
    if not cat: cat = 'all'
    if not date: date = 'latest'
    if not offset: 
        offset = 1 
    else: 
        offset = int(offset)
 
    
    
    listDict = showList(request,city,cat,date,offset)
    

    i=len(listDict['navigationList'])
    
    
    nv=[]
    #import copy 
    catss= NewCatUrl(2,city)
    catt=listDict['navigationList'][i-1]
    try:
        cstr=catss[catt['id']]['child']
        if not cstr :
            cstr=catss[catss[catt['id']]['fid']]['child']
    except:
        return render_to_response('not.html',{'list':[]},context_instance=RequestContext(request))
        
    if not cstr :
        for k in range(i):
            
            if k==3:
                break
            nv.append(listDict['navigationList'][i-1-k])
        cstr=[] 
        le=len(nv)
        for kh in range(le):        
            if nv[le-1-kh].has_key('id'):
                cat_k=[]      
                for ch in catss[nv[le-1-kh]['id']]['child']:
                    for n in nv:
                        if n.has_key('id'):
                            if ch['id']==n['id']:
                                ch['flag'] = 'true'
                    
                    if ch['ename']:
                        cat_k.append(ch)
                cstr.append(cat_k)
        
    listDict['cat_k']=cstr
    if len(listDict['list'])>0:
        listDict['city_py']=city
        listDict['len_list']=len(listDict['list'])
        try:
            listDict['cat']=int(cat)
        except:
            listDict['cat']=cat
        listDict['page']=offset
        listDict['offset']=10
        

        for nv in listDict['navigationList']:
            try:
                if nv['ename']=='travel':
                    return render_to_response('m_travel_list.html',listDict,context_instance=RequestContext(request))
                    break
            except:
                pass
        #travel
        #return render_to_response('m_travel_list.html',listDict,context_instance=RequestContext(request))
        return render_to_response('m_list.html',listDict,context_instance=RequestContext(request))
    else:
        return render_to_response('not.html',{'list':[]},context_instance=RequestContext(request))    
Ejemplo n.º 20
0
def list_page(request,city='city',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
    '''

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

    lead_cat = 'meeting'

    if request.GET.get('db'):
        new = True
    else:
        new = False

    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 month_int not in range(0,13):
        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 city == '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]] + 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]:
        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 = ''

    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
    

    ######################
    #info of current page#
    ######################
    listDict = {}

    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'不限'

    #do not include 'page='
    url_tail = [['tag', tag_name], ['cal', cal_flag]]
    url_tail_for_cat = [['cal', cal_flag]]


    ################
    #filter options#
    ################
    #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)


    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/'


    ##################
    #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
        #listDict['switch_link'] = '/' + '/'.join([lead_cat, city, cat, month, '?tag='+ tag_name])
        listDict['switch_link'] = '/' + '/'.join([city, cat, month, '?tag='+ tag_name])
        listDict['calendar_table'] = calendar_page(cat, city_info, date_in, tag_id, new)
        #listDict['reset_link'] = '/' + '/'.join([lead_cat, 'city', lead_cat, str(today.month).zfill(2)]) + '?cal=1'
        listDict['reset_link'] = '/' + '/'.join(['city', lead_cat, str(today.month).zfill(2)]) + '?cal=1'


    else:
        if month:
            #listDict['switch_link'] = '/' + '/'.join([lead_cat, city, cat, month, '?tag='+ tag_name + '&cal=1'])
            listDict['switch_link'] = '/' + '/'.join([city, cat, month, '?tag='+ tag_name + '&cal=1'])
        else:
            listDict['switch_link'] = '/' + '/'.join([city, cat, str(today.month).zfill(2), '?tag='+ tag_name + '&cal=1'])

        #listDict['reset_link'] = '/' + '/'.join([lead_cat, 'city', lead_cat, '00'])
        listDict['reset_link'] = '/' + '/'.join(['city', lead_cat, '00'])


        #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='')

        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)


    #####
    #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())
    else:
        html_head_tag = ''

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


    return render(request, 's_list.html', listDict)
Ejemplo n.º 21
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")
Ejemplo n.º 22
0
def getListHeadNew(city ,cat ,date):
    city_name=city[1]
    cat_id_li=NewCatUrl(False,city[2])
    if cat.isdigit():
        cat=int(cat)
        
    data_str=''
    if 'thisweek' == date:
        startTime = datetime.date.today()+relativedelta(weekday=MO(-1))
        #next week monday
        endTime = datetime.date.today()+relativedelta(days=+1,weekday=MO)
        
        data_str=u'%s年%s月%s-%s日' % (startTime.year,startTime.month,startTime.day,endTime.day)
        #data_str=datetime.datetime.strftime(startTime,'%Y年%m月%d')
        #data_str+=datetime.datetime.strftime(endTime,'-%d')
        #data_str+=u"日"
    elif 'nextweek' == date:
        #next week monday
        startTime = datetime.date.today()+relativedelta(days=+1,weekday=MO)
        #after next week monday
        endTime = startTime+relativedelta(days=+1,weekday=MO)
        #next week SUNDAY
        #endTime = today+relativedelta(days=+7,weekday=SU)datetime
        datetime.date.year
        data_str=u'%s年%s月%s-%s日' % (startTime.year,startTime.month,startTime.day,endTime.day)
        #data_str=datetime.datetime.strftime(startTime,'%Y年%m月%d')
        #data_str+=datetime.datetime.strftime(endTime,'-%d')
        #data_str+=u"日"
    elif 'nextmonth' == date:
        thisMonthStart = datetime.datetime.now().strftime('%Y-%m-1')
        tmp = thisMonthStart.split('-')
        thisMonthStart = datetime.datetime(int(tmp[0]), int(tmp[1]),int(tmp[2]))
        startTime = thisMonthStart+relativedelta(months=+1)
        endTime = thisMonthStart+relativedelta(months=+2)
        data_str=u'%s年%s月' % (startTime.year,startTime.month)
        #data_str=datetime.datetime.strftime(startTime,'%Y年%m月')

    elif date == 'new':
        data_str=u'最新'

    
    head_list={}
    if cat_id_li.has_key( cat ):
        catname=cat_id_li[cat]['catname']
        if cat_id_li[cat]['seo']:
            head_list = cat_id_li[cat]['seo']
    else:
        catname=''
        head_list=None
            

    if  head_list:
        if head_list.has_key('title'):
            head_list['title']=head_list['title'].replace('XX',city_name).replace(u'大活动',u'活动家') 
            head_list['title']=head_list['title'].replace('(city)',city_name)
            head_list['title']=head_list['title'].replace('(date)',data_str)
            head_list['title']=head_list['title'].replace('(cat)',catname)
        else:
            head_list['title']=u'会议网_活动网_公开课培训_%s展会_活动家'%city_name
        
        if head_list.has_key('keywords'):
            head_list['keywords']=head_list['keywords'].replace('XX',city_name).replace(u'大活动',u'活动家')
            head_list['keywords']=head_list['keywords'].replace('(city)',city_name)
            head_list['keywords']=head_list['keywords'].replace('(date)',data_str)
            head_list['keywords']=head_list['keywords'].replace('(cat)',catname)
        else:
            head_list['keywords']=u'会议网,活动网,商务活动,公开课培训,%s展览,%s展会,%s会展,%s会议'%(city_name,city_name,city_name,city_name)
        
        if head_list.has_key('description'):
        
            head_list['description']=head_list['description'].replace('XX',city_name).replace(u'大活动',u'活动家')
            head_list['description']=head_list['description'].replace('(city)',city_name)
            head_list['description']=head_list['description'].replace('(date)',data_str)
            head_list['description']=head_list['description'].replace('(cat)',catname)
        else:
            head_list['description']=u'活动家www.huodongjia.com为你提供会议报名,会展参展,公开课报名服务。服务热线:400-003-3879'
        head =head_list
    else:
        head = getListHead(city ,cat ,date)
        
    return head