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")
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)
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)
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)
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
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
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))
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
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
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))
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)