コード例 #1
0
ファイル: admin_operate.py プロジェクト: sureboy/xiaorizi
 def save_model(self, request, obj, form, change):
     ci=NewCity(3)
     if not ci.has_key(obj.title):
         NewCity(3,True)
     
    
     obj.save()
コード例 #2
0
ファイル: common.py プロジェクト: sureboy/xiaorizi
def find_from_city(request,city_title=False):
     
    cityObj=()
    if not city_title:
        try:
            title = request.COOKIES.get('city_py',False)
            city_name = request.COOKIES.get('city',False)
            cityId = request.COOKIES.get('city_id',False)
            
            city_name = city_name.decode('utf-8')
            cityObj=(cityId,city_name,title)
             
        except:
            pass
        
           
        if not title or not city_name or not cityId: 
            city_code = getCityNameByIp(request)
            if city_code:
                ci=NewCity(4)
                if  ci.has_key(city_code):            
                    cityObj =ci[city_code]
                    
        if cityObj:
            return cityObj

    else:
        ci=NewCity(3)
        if  ci.has_key(city_title):    
            cityObj =ci[city_title]
            return cityObj
                    
        
 
 
    cityId = 101
    city_name = u'北京'
    title = 'beijing'
    cityObj=(cityId,city_name,title,False)
        
        
    return cityObj
コード例 #3
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 ''
コード例 #4
0
def find_from_city(request, city_title=False):

    cityObj = ()
    if not city_title:
        try:
            title = request.COOKIES.get('city_py', False)
            city_name = request.COOKIES.get('city', False)
            cityId = request.COOKIES.get('city_id', False)

            city_name = city_name.decode('utf-8')
            cityObj = (cityId, city_name, title)

        except:
            pass

        if not title or not city_name or not cityId:
            city_code = getCityNameByIp(request)
            if city_code:
                ci = NewCity(4)
                if ci.has_key(city_code):
                    cityObj = ci[city_code]

        if cityObj:
            return cityObj

    else:
        ci = NewCity(3)
        if ci.has_key(city_title):
            cityObj = ci[city_title]
            return cityObj

    cityId = 101
    city_name = u'北京'
    title = 'beijing'
    cityObj = (cityId, city_name, title, False)

    return cityObj
コード例 #5
0
ファイル: admin_operate.py プロジェクト: sureboy/xiaorizi
    def save_model(self, request, obj, form, change):
        ci = NewCity(3)
        if not ci.has_key(obj.title):
            NewCity(3, True)

        obj.save()
コード例 #6
0
ファイル: list_cal.py プロジェクト: sureboy/xiaorizi
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)
コード例 #7
0
ファイル: list_cal_20150210.py プロジェクト: sureboy/xiaorizi
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)
コード例 #8
0
ファイル: m_views.py プロジェクト: sureboy/xiaorizi
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
コード例 #9
0
ファイル: list_cal_20150210.py プロジェクト: sureboy/xiaorizi
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)
コード例 #10
0
ファイル: views.py プロジェクト: sureboy/xiaorizi
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")
コード例 #11
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))
コード例 #12
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]
            cat_n = []
            cat_n.append({
                'caturl': '/%s/meeting/' % out[0],
                'catname': u'商务会议',
                'ename': u'meeting',
                'flag': False
            })
            cat_n.append({
                'caturl': '/%s/travel/' % out[0],
                'catname': u'旅行体验',
                'ename': u'travel',
                'flag': False
            })
            cat_n.append({
                'caturl': '/%s/show/' % out[0],
                'catname': u'娱乐演出',
                'ename': u'show',
                'flag': False
            })
            cat_n.append({
                'caturl': '/%s/local/' % out[0],
                'catname': u'同城活动',
                'ename': u'local',
                'flag': False
            })
        else:
            out[0] = 'beijing'
            '''
            try:
                cat_n=NewCatUrl(1,out[0])
                if 0==len(cat_n):
                    cat_n=NewCatUrl(1,out[0],True)
            except:
                cat_n=[]
            '''
            cat_n = []
            cat_n.append({
                'caturl': '/beijing/meeting/',
                'catname': u'会议',
                'ename': u'meeting',
                'flag': False
            })
            cat_n.append({
                'caturl': '/beijing/travel/',
                'catname': u'旅行体验',
                'ename': u'travel',
                'flag': False
            })
            cat_n.append({
                'caturl': '/beijing/show/',
                'catname': u'演出',
                'ename': u'show',
                'flag': False
            })
            cat_n.append({
                'caturl': '/beijing/local/',
                'catname': u'同城活动',
                'ename': u'local',
                'flag': False
            })
            #cat_n.append({'caturl':'/beijing/local','catname':u'同城活动','ename':u'local','flag':False})
        context['Show_Nav'] = []
        context['cat_Map'] = cat_n

        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'] = '201410181'

        www = {
            'id':
            2,
            'name':
            '互联网会议',
            'img':
            'http://pic.huodongjia.com/html5/pic/www1.png?time=%s' %
            context['time'],
            'url':
            '/%s/it/' % out[0]
        }
        jinrong = {
            'id':
            6,
            'name':
            '金融会议',
            'img':
            'http://pic.huodongjia.com/html5/pic/jinrong1.png?time=%s' %
            context['time'],
            'url':
            '/%s/finance/' % out[0]
        }
        hospity = {
            'id':
            23,
            'name':
            '医疗会议',
            'img':
            'http://pic.huodongjia.com/html5/pic/hospity1.png?time=%s' %
            context['time'],
            'url':
            '/%s/medical/' % out[0]
        }
        maer = {
            'id':
            93,
            'name':
            '骑马运动',
            'img':
            'http://pic.huodongjia.com/html5/pic/maer1.png?time=%s' %
            context['time'],
            'url':
            '/tag/?keyword=骑马运动'
        }
        fly = {
            'id':
            94,
            'name':
            '飞行体验',
            'img':
            'http://pic.huodongjia.com/html5/pic/fly1.png?time=%s' %
            context['time'],
            'url':
            '/tag/?keyword=飞行体验'
        }
        foot = {
            'id':
            76,
            'name':
            '美食烹饪',
            'img':
            'http://pic.huodongjia.com/html5/pic/foot1.png?time=%s' %
            context['time'],
            'url':
            '/%s/food/' % out[0]
        }
        child = {
            'id':
            24,
            'name':
            '亲子活动',
            'img':
            'http://pic.huodongjia.com/html5/pic/child1.png?time=%s' %
            context['time'],
            'url':
            '/tag/?keyword=亲子活动'
        }
        snow = {
            'id':
            24,
            'name':
            '滑雪活动',
            'img':
            'http://pic.huodongjia.com/html5/pic/snow1.png?time=%s' %
            context['time'],
            'url':
            '/tag/?keyword=滑雪活动'
        }

        context['hot_cat'] = [
            www, jinrong, hospity, maer, fly, foot, child, snow
        ]

        return ''
コード例 #13
0
ファイル: list_cal.py プロジェクト: sureboy/xiaorizi
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)
コード例 #14
0
ファイル: views.py プロジェクト: sureboy/xiaorizi
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")