def showQ(request,query=False,template_name='q_showEvent.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('not.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('not.html',{'error_msg':u'活动没有发布' }) note=None for con in event['event_content']: if con[0] in [u'购买须知']: note=con break body={'note':note, 'event_id':event['event_id'] } return render_to_response(template_name,body,context_instance=RequestContext(request))
def showCont(request,query=False,template_name='s_showEvent.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('not.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('not.html',{'error_msg':u'活动没有发布' }) note=[] for i in range(len(event['event_content'])): event['event_content'][i]=(event['event_content'][i][0],event['event_content'][i][1].replace('<br>','')) if i is 0: note.append(event['event_content'][i]) elif event['event_content'][i][0] in [u'行程安排']: note.append(event['event_content'][i]) body={'note':note, 'event_id':event['event_id'], 'event_name':event['event_name'] } return render_to_response(template_name,body,context_instance=RequestContext(request))
def showCont(request,query=False,template_name='s_showEvent.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('not.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('not.html',{'error_msg':u'活动没有发布' }) note=[] for i in range(len(event['event_content'])): event['event_content'][i]=(event['event_content'][i][0],event['event_content'][i][1].replace('<br>','')) if i is 0: note.append(event['event_content'][i]) elif event['event_content'][i][0] in [u'行程安排']: note.append(event['event_content'][i]) body={'note':note, 'event_id':event['event_id'], 'event_name':event['event_name'] } return render_to_response(template_name,body,context_instance=RequestContext(request))
def showQ(request,query=False,template_name='q_showEvent.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('not.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('not.html',{'error_msg':u'活动没有发布' }) note=None for con in event['event_content']: if con[0] in [u'购买须知']: note=con break body={'note':note, 'event_id':event['event_id'] } return render_to_response(template_name,body,context_instance=RequestContext(request))
def show_list(request, city, cat, date, tag_id, perpage, offset, new=False): ''' city is tuple return a list of event-dict of only one specific page ''' offset = int(offset) cout = perpage * (offset - 1) try: url = request.META['PATH_INFO'] if url[-1] == "/": url = url[:-1] except: url = '' #################### #new = Ture, read from database mlist = get_event_list_by_ccdt(cat=cat, city=city, date=date, page=cout, offset=cout + perpage, order='-rel_time', new=new, tag_id=tag_id) tmp = [] if mlist: print mlist for item in mlist: tmp.append(NewformatEvent(False, item)) listDict = {'list': tmp} return listDict
def writeOrder(request, event_id): #print 1 #title = request.COOKIES.get('city_py',False) #city_name = request.COOKIES.get('city',False) if request.method == 'POST': eventId = int(event_id) ne = NewEventTable.objects.get(old_event_id=eventId) event = NewformatEvent(ne) info = request.POST pr = info.get('price', False) if pr and int(pr) > 0 and info.get('cheapMoney', False) and info.get( 'ticketNum', False): #currencyDic = {"RMB":1,"HKD":1.24,"TWD":4.84,"USD":0.16,"EUR":0.12,"GBP":0.095,"JPY":16.33,"THB":5.23,"KER":164.46,"SGD":0.2,"VND":3388.90,"MYR":0.52} ra = ne.Price.Currency.rate if ne.Price.Currency else 1 price = '%.2f' % (float(info['price']) / float(ra)) raw_price = info['price'] cheapMoney = info['cheapMoney'] ticketNum = info['ticketNum'] return render_to_response( 'form.html', { 'city': event['district_name'], 'city_py': event['district_title'], 'price': price, 'cheapMoney': cheapMoney, 'ticketNum': ticketNum, 'event': event, 'raw_price': raw_price, 'price_unit': event['event_price_unit'], 'price_unit_name': event['event_price_unit_name'], }, context_instance=RequestContext(request)) return HttpResponseRedirect('http://www.huodongjia.com/event-%s.html' % event_id)
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 doSubmitOrder(request, cds, eventId, orderFrom): try: orderFromDict = {0: '网站', 1: 'app', 2: '手机站', 3: '微信'} #pn=NewEventTable.objects.get(old_event_id=eventId,isshow_id__in=(1,8)) event = NewformatEvent(None, eventId) city_name = event['district_name'] number = '%s%s' % (int(time.time()), random.randint(100, 1000)) totalpay = float(cds['price']) * int(cds['number']) if int(totalpay) == 0: return (False, None, None) if request.META.has_key('HTTP_X_FORWARDED_FOR'): ip = request.META['HTTP_X_FORWARDED_FOR'] else: ip = request.META['REMOTE_ADDR'] NewOrder.objects.create( order_number=number, order_user_name=cds.get('name', ''), order_tel=cds.get('mobilphone', ''), order_email=cds.get('email', ''), order_totalpay=totalpay, order_price=cds.get('price', ''), order_amount=cds.get('number', ''), order_address=cds.get('address', ''), order_payment=cds.get('payMode', ''), order_telphone=cds.get('phone', ''), order_reg_fields=cds.get('reg_fields', 0), order_pay_status=0, order_status=0, event_id=event['event_id'], event_name=cds.get('event_name', ''), city_title=city_name, #order_reg_fields = 0, order_userid=0, order_addtime=time.time(), order_addip=ip, order_text=cds.get('remark', ''), event_to=orderFrom, ) subject = '活动家 来自%s订单通知.客户:%s,电话:%s' % ( orderFromDict[orderFrom], cds.get('name', '').encode('utf-8'), cds.get('mobilphone', '').encode('utf-8')) content = '点单号:%s\n总价:%s\n' % (number, totalpay) content += dic2text(cds) #sendMail(subject,content) msgs = u'您好,您预定的《%s》项目还未付款,请继续安排支付,支付成功后将有短信或电邮通知,请注意查收。【活动家】' % ( re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name', ''))) SendOrderMsg(cds.get('mobilphone', ''), msgs) url_log = request.COOKIES.get('urllogorder', None) if url_log: cache.set('order_%s' % number, [json.loads(url_log), ip], 86400 * 30) except Exception, e: log.debug(e) return (False, None, None)
def SearchKey(request): cds = request.GET keyword = cds.get('keyword', None) city = cds.get('city', None) cityObj = find_from_city(request, city) (page, offset) = getPageAndOffset(cds) list_s = [] ids = None if not keyword: return HttpResponse(json.dumps({ "code": 0, "msg": "Only GETs are allowed", "list": [] }), content_type="application/json") if len(keyword) > 20: return HttpResponse(json.dumps({ "code": 0, "msg": "keyword Fail", "list": [] }), content_type="application/json") else: #events_lis = mc.get(keyword+'_search_lis') keyword = keyword.replace('/', ' ') ids = cache.get('_'.join(keyword.split()) + '_search_lis') if not ids: ids = search(keyword) if ids: cache.set('_'.join(keyword.split()) + '_search_lis', ids, 300) events_lis = NewEventTable.objects.filter( old_event__in=ids ) #.order_by('district_id='+str(district_id),'event_begin_time') if cityObj: events_lis = events_lis.filter(city=cityObj[0]) start = (page - 1) * offset end = page * offset list_s = [ NewformatEvent(None, item.old_event_id) for item in events_lis[start:end] ] #response = json.dumps(p) #return HttpResponse(response, mimetype="application/json") return render_to_response('m_list.html', {'list': list_s}, context_instance=RequestContext(request))
def calculate(e): """ try: #只选取第一个关联地址为展示的地址 e.place = e.city.all()[0].district_name except IndexError: e.place = "" if e.begin_time and e.end_time: e.time_range = str(e.begin_time.month) + "." + str(e.begin_time.day) + "-" + str(e.end_time.day) else: e.time_range = '' return e """ return NewformatEvent(None, e.old_event_id)
def writeZhuantiOrder(request,event_id): #title = request.COOKIES.get('city_py',False) #city_name = request.COOKIES.get('city',False) eventId= int(event_id) ne=NewEventTable.objects.get(old_event_id=eventId) event = NewformatEvent(ne) print '1' pricecontent = '' for item in event['event_content']: if item[0] == u'会议门票': pricecontent = item break return render_to_response('zhuanti_order.html',{'city':event['district_name'], 'city_py':event['district_title'], 'event':event, 'price_txt':pricecontent,},context_instance=RequestContext(request))
def SearchKey(request): cds = request.GET keyword = cds.get('keyword',None) city = cds.get('city',None) cityObj = find_from_city(request,city) (page,offset) = getPageAndOffset(cds) list_s=[] ids=None if not keyword: return render_to_response('not.html',{'list':list_s},context_instance=RequestContext(request)) #return HttpResponse(json.dumps({"code":0,"msg":"Only GETs are allowed","list":[]}), content_type="application/json") if len(keyword) > 20: return render_to_response('not.html',{'list':list_s},context_instance=RequestContext(request)) #return HttpResponse(json.dumps({"code":0,"msg":"keyword Fail","list":[]}), content_type="application/json") else: #events_lis = mc.get(keyword+'_search_lis') keyword= keyword.replace('/',' ') ids = cache.get('_'.join(keyword.split())+'_search_lis') if not ids: ids = search(keyword) if ids: cache.set('_'.join(keyword.split())+'_search_lis',ids,300) events_lis = NewEventTable.objects.filter(old_event__in = ids)#.order_by('district_id='+str(district_id),'event_begin_time') if cityObj: events_lis = events_lis.filter(city=cityObj[0]) start = (page-1)*offset end = page*offset list_s = [NewformatEvent(None,item.old_event_id) for item in events_lis[start:end]] #response = json.dumps(p) #return HttpResponse(response, mimetype="application/json") head = {'title':u'%s_门票预订_报名参加_活动网_活动家'%(keyword), 'keywords':u'%s,门票,报名,活动网,活动家'%(keyword), 'description':u'找%s相关近期活动,就上【活动家www.huodongjia.com】。活动家为您提供%s相关活动信息,包含门票预订、报名参加、价格咨询等全方位服务,实时更新%s最新活动,随时随地轻松购票!服务热线:400-003-3879'%(keyword,keyword,keyword)} if len(list_s)>0: return render_to_response('m_tag.html',{'head':head,'city':request.COOKIES.get('city',u'北京'),'city_py':request.COOKIES.get('city_py','beijing'),'list':list_s,'len_list':len(list_s),'keyword':keyword,'page':page,'offset':offset},context_instance=RequestContext(request)) else: return render_to_response('not.html',{'list':list_s},context_instance=RequestContext(request))
def show_post_html(request, query=False, new=False): #return render_to_response('show_post.html',{'error_msg':u'活动 没有发布' }) if not query: query = 58823 p = {} p['begin'] = False event = NewformatEvent(False, query, new) if event['event_begin_time']: if datetime.datetime.strptime( event['event_begin_time'], "%Y-%m-%d").date() == datetime.date.today(): p['begin'] = True #n_event=NewEventTable.objects.get(id=event['id']) #n_event.rel_time=datetime.datetime.now() #n_event.save() #p['ca']=new p['info'] = event response = json.dumps(p) return HttpResponse(response, mimetype="application/json")
def SearchKey_ajax(request): cds = request.GET keyword = cds.get('keyword',None) city = cds.get('city',None) cityObj = find_from_city(request,city) (page,offset) = getPageAndOffset(cds) p={} if not keyword: return HttpResponse(json.dumps({"code":0,"msg":"Only GETs are allowed","list":[]}), content_type="application/json") if len(keyword) > 20: return HttpResponse(json.dumps({"code":0,"msg":"keyword Fail","list":[]}), content_type="application/json") else: #events_lis = mc.get(keyword+'_search_lis') keyword= keyword.replace('/',' ') ids = cache.get('_'.join(keyword.split())+'_search_lis') p['code']=1 p['msg']='Request is successful' p['keys']=keyword p['list'] =[] if not ids: ids = search(keyword) if ids: cache.set('_'.join(keyword.split())+'_search_lis',ids,300) events_lis = NewEventTable.objects.filter(old_event__in = ids)#.order_by('district_id='+str(district_id),'event_begin_time') if cityObj: events_lis = events_lis.filter(city=cityObj[0]) start = (page-1)*offset end = page*offset p['list'] = [NewformatEvent(None,item.old_event_id) for item in events_lis[start:end]] p['page']=page+1 response = json.dumps(p) return HttpResponse(response, mimetype="application/json")
def calculate(e): return NewformatEvent(None, e.old_event_id)
def showPage(request, query=False): #def showPage(request,query=False,template_name='show_event.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('base_error.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('base_error.html',{'error_msg':u'活动没有发布' }) ################## #2015.1.28 tp_prt_dir = 'zhuanti/' #template_name = tp_prt_dir + event['ename'] + '.html' #url_name = tp_prt_dir + zhuanti + '.html' #if template_name == url_name: # try: # template.loader.get_template(template_name) # except template.TemplateDoesNotExist: # template_name = tp_prt_dir + 'event.html' #else: # raise Http404 template_name = tp_prt_dir + event['ename'] + '.html' ################ #city_t=event['district_title'] #city_n=event['district_name'] city_t = '' city_n = '' console_success = False if saveConsult(request,event['event_id'],event['event_name']) == True: console_success = True suggestion_success = False if saveSuggestion(request,event['event_id'],event['event_name']) == True: suggestion_success = True qu=False ''' for i in range(len(event['event_content'])): if event['event_content'][i][0]==u'会议通知': ko=event['event_content'][i] del event['event_content'][i] event['event_content'].insert(0,ko) if event['event_content'][i][0]==u'会议门票': ko=event['event_content'][i] del event['event_content'][i] event['event_content'].insert(1,ko) ''' for con in event['event_content']: if con[0]==u'常见问题': qu=True break if not qu: fid=find_cat_fid(NewCatUrl(2),event['catid'],city_t) ark=False for f in fid: if f['article']: for ar in f['article']: if ar['name']==u'常见问题': event['event_content'].append((ar['name'],ar['content'].replace('pic1.qkan.com','pic.huodongjia.com'),)) ark=True qu=True break if ark: break ''' if cache.has_key('rec_with_cat_%s'%event['event_cat']): recommend_list = cache.get('rec_with_cat_%s'%event['event_cat']) else: ''' #recommend_list = NowEvent.objects.filter(Q(event_isshow=1)|Q(event_isshow=8),event_cat=event['event_cat']).exclude(event_id = event['event_id']).exclude(event_time_expire = 2).order_by('event_begin_time') #randloc = randint(0,len(recommend_list)/2) #number = 6 #event_city_tag new=False if event.has_key('event_tag_id'): tran_rec_list=event_city_tag(event['district_id'],tuple(event['event_tag_id']),new) else: tran_rec_list =event_city_cat(None,event['catid'],new) if event['has_picture']: number=4 else: number=6 l= len(tran_rec_list)-number if l<0: b = event_city_cat(None,None,new ) #print b tran_rec_list.extend(b [:abs(l)+1] ) #tran_rec_list =[]# [formatEvent(item) for item in recommend_list[randloc:randloc+number]] tran_rec_list_new=[] for tr in tran_rec_list: if tr['event_id']!=event['event_id']: tran_rec_list_new.append(tr) body={'head':event['head'], 'event':event, 'user_viewed_events':tran_rec_list_new[:number], 'city':city_n, 'console_success':console_success, 'suggestion_success':suggestion_success, 'city_py':city_t, 'navigationList':event['navigationList']} if event.has_key('cf'): body['cf']=event['cf'] return render_to_response(template_name,body,context_instance=RequestContext(request))
def showOrder(request, event_id): try: new = False if request.GET.get('db') and request.user.is_authenticated(): new = True event = NewformatEvent(None, int(event_id), new=new) city_s = None map_city_list = city_ss() for map in map_city_list: if map.has_key('child'): for ma in map['child']: if ma['id'] == event['district_id']: city_s = map['district_name'] break if city_ss: break #construct head seo info error = False try: st = event['event_begin_time'].split('-') et = event['event_end_time'].split('-') info_dict = {'name': event['event_name'], \ 'city': event['district_name'] } info_dict['sy'] = st[0] info_dict['sm'] = st[1] info_dict['sd'] = st[2] info_dict['em'] = et[1] info_dict['ed'] = et[2] #handle some error except KeyError: error = True except IndexError: error = True if error: info_dict['sy'] = 0 info_dict['sm'] = 0 info_dict['sd'] = 0 info_dict['em'] = 0 info_dict['ed'] = 0 # head = {} head['title'] = u"{name}门票预订_活动家".format(**info_dict) head['keywords'] = u'{name},订票'.format(**info_dict) head['description'] = \ u'这里是{name}门票预订页面。{name}参会,就上【活动家www.huodongjia.com】。{name}将于{sy}年{sm}月{sd}至{em}月{ed}在{city}举办。'.format(**info_dict) return render_to_response( 'new_form.html', { 'city': event['district_name'], 'city_py': event['district_title'], 'city_ss': city_s, 'event': event, 'head': head, 'price': request.GET.get('price', None), 'number': request.GET.get('number', None), 'price_unit': event['event_price_unit'], 'price_unit_name': event['event_price_unit_name'], }, context_instance=RequestContext(request)) except: return HttpResponseRedirect('/event-%s.html' % event_id)
def list_page_subscribe(request): var = {} if request.method == 'POST': cat_ids = request.POST.get('cat_id', None) tag_ids = request.POST.get('tag_id', None) email = request.POST.get('email', None) if not cat_ids and not tag_ids: var['success'] = False return HttpResponse(json.dumps(var), content_type='application/json') try: subinfo = SubscribeInfo.objects.get(email=email) if cat_ids: subinfo.cats = ',' + string_cat(subinfo.cats, cat_ids) + ',' if tag_ids: subinfo.keywords = ',' + string_cat(subinfo.keywords, tag_ids) + ',' except ObjectDoesNotExist: subinfo = SubscribeInfo(email=email, keywords=',' + tag_ids + ',', cats=',' + cat_ids + ',') subinfo.save() var['success'] = True cat_id_int = [] for i in subinfo.cats.split(','): if i and i.isdigit(): cat_id_int.append(int(i)) tag_id_int = [] for i in subinfo.keywords.split(','): if i and i.isdigit(): tag_id_int.append(int(i)) new = False cat_total = get_cat_total(new) cat_total = filter(lambda x: x['id'] in cat_id_int, cat_total) tag_total = get_tag_total(new) tag_total = filter(lambda x: x['id'] in tag_id_int, tag_total) #send email to huodongjia and subscriber mail_title = u'活动家订阅成功!' if cat_total: ev_list = get_event_list_by_ccdt(cat=cat_total[0]['ename'], city=(0, '', ''), date=None, page=1, offset=5, order=False, new=new, tag_id='') rcmd = [NewformatEvent(False, item) for item in ev_list] main_site = 'http://www.huodongjia.com' ev_list = [{ 'name': ev['event_name'], 'url': main_site + reverse('new_event:event_detail', args=(ev['event_id'], )), 'pic': ev['event_img'], 'begin_time': ev['event_begin_time'], 'end_time': ev['event_end_time'], 'address': u','.join( filter(lambda x: x, [ev['district_name'], ev['event_address']])) } for ev in rcmd] cnt_cat = u'、'.join([i['name'] for i in cat_total]) cnt_tag = u'、'.join([i['name'] for i in tag_total]) unsub_url = main_site text = get_template('subemail/email.txt') html = get_template('subemail/email.html') d = Context({ 'cats': cnt_cat, 'tags': cnt_tag, 'ev_list': ev_list, 'unsubscribe': unsub_url, }) text_content = text.render(d) html_content = html.render(d) email_info = sendMail(mail_title.encode('utf-8'), text_content.encode('utf-8'), html_content.encode('utf-8'), to_list=[email]) text_content = email + text_content html_content = email + html_content email_info = sendMail(mail_title.encode('utf-8'), text_content.encode('utf-8'), html_content.encode('utf-8')) #to_list=['*****@*****.**']) return HttpResponse(json.dumps(var), content_type='application/json')
def submitOrder_weixin(request): title = request.COOKIES.get('city_py',False) city_name = request.COOKIES.get('city',False) if request.method == 'POST': cds = request.POST error = False if not cds.get('name',''): error = True if not cds.get('mobilphone',''): error = True if not cds.get('address',''): error = True eventId = int(cds.get('event_id','0')) if not eventId: error = True else: try: pn=NewEventTable.objects.get(old_event_id=eventId,isshow_id__in=(1,8)) event = NewformatEvent(pn) #return HttpResponse(json.dumps({'flag':event})) #event = NewEventTable.objects.get(Q(event_isshow=1)|Q(event_isshow=8),id=eventId) if event['event_price_model'] != 2: if event['event_price_model'] == 1: priceString = event['event_discount_price'] else: priceString = event['event_price'] priceList = priceString.split('/') #return HttpResponse(json.dumps({'flag':priceList})) #currencyDic = [1,1,1.24,4.84,0.16,0.12,0.095,16.33,5.23,164.46,0.2,3388.90,0.52] for i in range(len(priceList)): if priceList[i].replace('.','').isdigit(): ra=pn.Price.Currency.rate if pn.Price.Currency else 1 priceList[i] = '%.2f'% (float(priceList[i])/float(ra) ) if '%.2f'%float(cds.get('price')) not in priceList: return HttpResponse(json.dumps({'flag':priceString})) error = True except: return HttpResponse(json.dumps({'flag':1})) error = True if not error: city_name =event['district_name'] number = '%s%s'%(int(time.time()),random.randint(100,1000)) totalpay = float(cds['price'])*int(cds['number']) #print cds['payMode'] if request.META.has_key('HTTP_X_FORWARDED_FOR'): ip = request.META['HTTP_X_FORWARDED_FOR'] else: ip = request.META['REMOTE_ADDR'] NewOrder.objects.create( order_number=number, order_user_name=cds.get('name',''), order_tel = cds.get('mobilphone',''), order_email = cds.get('email',''), order_totalpay = totalpay, order_price = cds.get('price',''), order_amount = cds.get('number',''), order_address = cds.get('address',''), order_payment = 'weixin', order_telphone = cds.get('phone',''), order_pay_status = 0, order_status = 0, event_id = event['event_id'], event_name = cds.get('event_name',''), city_title = city_name, order_reg_fields = 0, order_userid = 0, order_addtime = time.time(), order_addip = ip, order_text = cds.get('remark',''), event_to=3, ) subject = '活动家 -来自微信的订单通知.客户:%s,电话:%s'%(cds.get('name','').encode('utf-8'),cds.get('mobilphone','').encode('utf-8')) content = '点单号:%s\n总价:%s\n'%(number,totalpay) content += dic2text(cds) sendMail(subject,content) #msgs= u'您好,您预定的《%s》项目还未付款,请继续安排支付,支付成功后将有短信或电邮通知,请注意查收。【活动家】' % (re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name',''))) #msgs= u'您好,你在活动家(huodongjia.com)预订了%s活动,还未支付,请你尽快支付,我们好为你出票。你可以在huodongjia.com上查询订单号%s支付即可。谢谢!【活动家】'\ # % (re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name','')),number) #print type(msgs) #SendOrderMsg(cds.get('mobilphone',''),msgs) url_log=request.COOKIES.get('urllogorder',None) if url_log: cache.set('order_%s' % number,[json.loads(url_log),ip],86400*30) ''' msg = u'活动家新的订单通知,活动名称:%s,客户:%s,电话:%s,单号:%s,总价:%s,'%( cds.get('event_name',''),cds.get('name',''),cds.get('mobilphone',''),number,totalpay) msg = re.sub(ur"[^\u4e00-\u9fa5\w]", ",", msg) try: SendOrderMsg('18628175526','%s【活动家】' % msg) except Exception,e: log.debug('order_c') log.debug(e) ''' return HttpResponseRedirect('/weixin/js_api_call.php?order_number=%s' % number) #return render_to_response('m_orderDetails.html',{'city':city_name,'city_py':title,'order_info':cds,'order_number':number,'total_price':totalpay},context_instance=RequestContext(request)) else: return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'下订单时遇到错误,请重新下单2'},context_instance=RequestContext(request)) return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'下订单时遇到错误,请重新下单1'},context_instance=RequestContext(request))
def showPage(request,query=False,template_name='m_event.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('not.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('not.html',{'error_msg':u'活动没有发布' }) city_t=event['district_title'] city_n=event['district_name'] qu=False for con in event['event_content']: if con[0]==u'常见问题': qu=True break if not qu: fid=find_cat_fid(NewCatUrl(2),event['catid'],city_t) ark=False for f in fid: if f['article']: for ar in f['article']: if ar['name']==u'常见问题': event['event_content'].append((ar['name'],ar['content'].replace('pic1.qkan.com','pic.huodongjia.com'),)) ark=True qu=True break if ark: break new=False tran_rec_list =event_city_cat(None,event['catid'],new) number=3 l= len(tran_rec_list)-number if l<0: b = event_city_cat(None,None,new ) #print b tran_rec_list.extend(b [:abs(l)] ) #tran_rec_list =[]# [formatEvent(item) for item in recommend_list[randloc:randloc+number]] body={'head':event['head'], 'event':event, 'list':tran_rec_list[:number], 'city':city_n, 'city_py':city_t, 'navigationList':event['navigationList']} if event.has_key('cf'): body['cf']=event['cf'] return render_to_response(template_name,body,context_instance=RequestContext(request))
def NewformatEvent_json(request, eventid=False, new=False): ev = NewformatEvent(False, eventid, new) response = json.dumps(ev) return HttpResponse(response, mimetype="application/json")
def searchKeyword(request,offset = 15,page = 1,isTag=False): #mc = memcache.Client(['127.0.0.1:11211']) title = request.COOKIES.get('city_py', '') city_name = request.COOKIES.get('city', '') cityObj = getCityObjFromTitle(title) district_id = 45052 if cityObj: district_id = cityObj[0] if offset < 1 or page < 1: return render_to_response('base_error.html',{'error_msg':u'页码错误'},context_instance=RequestContext(request)) offset = int(offset) page = int(page) error = u'你什么都没有输入' if request.GET.get('keyword',''): keyword = request.GET['keyword'] #keyword = keyword.encode('utf8') #print keyword.encode('utf8') ########################################## ##if tag in tags of categories of <business> #### jump to new business list page ########################################## bs = NewCatUrl()['business'] for c1 in bs['child']: cat = c1['ename'] if cat in ['expo', 'meeting', 'training']: continue for tag in c1['tag']: if 'name' in tag and keyword in tag['name']: return HttpResponseRedirect("/{cat}/?tag={tag}".format(cat=cat, \ tag=keyword.encode('utf-8'))) ############################ if keyword: if page == 1 and not isTag: if request.META.has_key('HTTP_X_FORWARDED_FOR'): ip = request.META['HTTP_X_FORWARDED_FOR'] else: ip = request.META['REMOTE_ADDR'] SysSearchKey.objects.create(keyword = keyword, ip = ip, search_time = time.time() ) if len(keyword) > 20: error = u'关键词的字数不能超过20' else: #events_lis = mc.get(keyword+'_search_lis') keyword= keyword.replace('/',' ') events_lis = cache.get('_'.join(keyword.split())+'_search_lis') if not events_lis: ids = search(keyword) if ids: events_lis = SysEvent.objects.filter(event_id__in = ids)#.order_by('district_id='+str(district_id),'event_begin_time') cache.set('_'.join(keyword.split())+'_search_lis',events_lis,300) if events_lis: events_lis = events_lis.extra(select={'is_top':'district_id='+str(district_id)}) events_lis = events_lis.extra(order_by=['-is_top']) #print connection.queries count = events_lis.count() if count%offset: page_number = count/offset+1 else: page_number = count/offset rlist = [NewformatEvent(False,item.event_id) for item in events_lis[offset*(page-1):offset*page]] if not isTag: url = '/search/'+str(offset)+'/page/?keyword='+keyword else: url = '/tag/'+str(offset)+'/page/?keyword='+keyword #print page_number pageList = [] for i in range(1,page_number+1): curPageFlg = False if page == i: curPageFlg = True pageDict = {'page':i, 'pageurl':url.replace('page',str(i)),'flag':curPageFlg} pageList.append(pageDict) if page <= 1: firstPage = False prePage = False else: firstPage = pageList[0] prePage = pageList[page-2] if page >= page_number: lastPage = False nextPage = False else: lastPage = pageList[page_number-1] nextPage = pageList[page] #print pageList head = {'title':u'%s相关热门会议查询与报名_活动家'%(keyword), 'keywords':u'%s相关会议,%s学术会议,%s工作会议' % \ (keyword, keyword, keyword), 'description':u'找%s方面相关会议信息,就上【活动家www.huodongjia.com】。活动家为您提供全面及时的%s方面的会议、峰会、论坛、年会介绍和查询报名服务,是上万主办方推崇的%s方面会议网站。学习提升,积累人脉,精准标签,个性定制,活动家服务热线:400-003-3879。' % (keyword, keyword, keyword)} return render_to_response('search_results.html',{'list':rlist, 'city':city_name, 'city_py':title, 'keyword':keyword, 'firstPage':firstPage, 'prePage':prePage, 'currentPage':page, 'nextPage':nextPage, 'lastPage':lastPage, 'pageList':pageList, 'head':head}) else: error = u'没能搜索到与"%s"相关的活动,你可以尝试其他搜索'%keyword clist = [] for i in [20,21,22,23,89,90]: cl = cache.get('rec_with_cat_%s'%i) if cl: for j in cl: if not random.randint(0,8): clist.append(j) rlist = [formatEvent(item) for item in clist] if clist: message = u'你可能感兴趣的活动' else: message = '' return render_to_response('search_results.html',{'error_msg':error,'message':message,'city':city_name,'city_py':title,'list':rlist},context_instance=RequestContext(request)) else: error = u'输入不能为空' return render_to_response('search_results.html',{'error_msg':error,'city':city_name,'city_py':title},context_instance=RequestContext(request))
def showPage(request, query=False): #def showPage(request,query=False,template_name='show_event.html'): event = {} if query.isdigit(): event = NewformatEvent(False, int(query), request.GET.get('new', False)) if not event.has_key('isshow'): return render_to_response('base_error.html', {'error_msg': u'没有该活动 '}) else: if not event['isshow'] in [1, 8]: return render_to_response('base_error.html', {'error_msg': u'活动没有发布'}) ################## #2015.1.28 tp_prt_dir = 'zhuanti/' #template_name = tp_prt_dir + event['ename'] + '.html' #url_name = tp_prt_dir + zhuanti + '.html' #if template_name == url_name: # try: # template.loader.get_template(template_name) # except template.TemplateDoesNotExist: # template_name = tp_prt_dir + 'event.html' #else: # raise Http404 template_name = tp_prt_dir + event['ename'] + '.html' ################ #city_t=event['district_title'] #city_n=event['district_name'] city_t = '' city_n = '' console_success = False if saveConsult(request, event['event_id'], event['event_name']) == True: console_success = True suggestion_success = False if saveSuggestion(request, event['event_id'], event['event_name']) == True: suggestion_success = True qu = False ''' for i in range(len(event['event_content'])): if event['event_content'][i][0]==u'会议通知': ko=event['event_content'][i] del event['event_content'][i] event['event_content'].insert(0,ko) if event['event_content'][i][0]==u'会议门票': ko=event['event_content'][i] del event['event_content'][i] event['event_content'].insert(1,ko) ''' for con in event['event_content']: if con[0] == u'常见问题': qu = True break if not qu: fid = find_cat_fid(NewCatUrl(2), event['catid'], city_t) ark = False for f in fid: if f['article']: for ar in f['article']: if ar['name'] == u'常见问题': event['event_content'].append(( ar['name'], ar['content'].replace('pic1.qkan.com', 'pic.huodongjia.com'), )) ark = True qu = True break if ark: break ''' if cache.has_key('rec_with_cat_%s'%event['event_cat']): recommend_list = cache.get('rec_with_cat_%s'%event['event_cat']) else: ''' #recommend_list = NowEvent.objects.filter(Q(event_isshow=1)|Q(event_isshow=8),event_cat=event['event_cat']).exclude(event_id = event['event_id']).exclude(event_time_expire = 2).order_by('event_begin_time') #randloc = randint(0,len(recommend_list)/2) #number = 6 #event_city_tag new = False if event.has_key('event_tag_id'): tran_rec_list = event_city_tag(event['district_id'], tuple(event['event_tag_id']), new) else: tran_rec_list = event_city_cat(None, event['catid'], new) if event['has_picture']: number = 4 else: number = 6 l = len(tran_rec_list) - number if l < 0: b = event_city_cat(None, None, new) #print b tran_rec_list.extend(b[:abs(l) + 1]) #tran_rec_list =[]# [formatEvent(item) for item in recommend_list[randloc:randloc+number]] tran_rec_list_new = [] for tr in tran_rec_list: if tr['event_id'] != event['event_id']: tran_rec_list_new.append(tr) body = { 'head': event['head'], 'event': event, 'user_viewed_events': tran_rec_list_new[:number], 'city': city_n, 'console_success': console_success, 'suggestion_success': suggestion_success, 'city_py': city_t, 'navigationList': event['navigationList'] } if event.has_key('cf'): body['cf'] = event['cf'] return render_to_response(template_name, body, context_instance=RequestContext(request))
def showPage(request,query=False,template_name='m_event.html'): event={} if query.isdigit(): event= NewformatEvent(False,int(query),request.GET.get('new',False)) if not event.has_key('isshow'): return render_to_response('not.html',{'error_msg':u'没有该活动 ' }) else: if not event['isshow'] in [1,8]: return render_to_response('not.html',{'error_msg':u'活动没有发布' }) city_t=event['district_title'] city_n=event['district_name'] qu=False for con in event['event_content']: if con[0]==u'常见问题': qu=True break if not qu: fid=find_cat_fid(NewCatUrl(2),event['catid'],city_t) ark=False for f in fid: if f['article']: for ar in f['article']: if ar['name']==u'常见问题': event['event_content'].append((ar['name'],ar['content'].replace('pic1.qkan.com','pic.huodongjia.com'),)) ark=True qu=True break if ark: break new=False tran_rec_list =event_city_cat(None,event['catid'],new) number=3 l= len(tran_rec_list)-number if l<0: b = event_city_cat(None,None,new ) #print b tran_rec_list.extend(b [:abs(l)] ) #tran_rec_list =[]# [formatEvent(item) for item in recommend_list[randloc:randloc+number]] body={'head':event['head'], 'event':event, 'list':tran_rec_list[:number], 'city':city_n, 'city_py':city_t, 'navigationList':event['navigationList']} if event.has_key('cf'): body['cf']=event['cf'] return render_to_response(template_name,body,context_instance=RequestContext(request))
def submitOrder(request): title = request.COOKIES.get('city_py', '') city_name = request.COOKIES.get('city', '') if request.method == 'POST': cds = request.POST error = False flg = False if not cds.get('name', ''): error = True return render_to_response('base_error.html', { 'city': city_name, 'city_py': title, 'error_msg': u'下订单时遇到错误,name' }, context_instance=RequestContext(request)) if not cds.get('mobilphone', ''): error = True return render_to_response('base_error.html', { 'city': city_name, 'city_py': title, 'error_msg': u'下订单时遇到错误,mobilphone' }, context_instance=RequestContext(request)) if not cds.get('address', ''): error = True return render_to_response('base_error.html', { 'city': city_name, 'city_py': title, 'error_msg': u'下订单时遇到错误,address' }, context_instance=RequestContext(request)) eventId = int(cds.get('event_id', '0')) if not eventId: return render_to_response('base_error.html', { 'city': city_name, 'city_py': title, 'error_msg': u'下订单时遇到错误,event_id' }, context_instance=RequestContext(request)) error = True if not error: #0 表示订单来源是网站 flg, number, totalpay = doSubmitOrder(request, cds, eventId, 0) if flg: response = render_to_response( 'orderDetails.html', { 'city': city_name, 'city_py': title, 'order_info': cds, 'order_number': number, 'total_price': totalpay, 'event': NewformatEvent(None, eventId) }, context_instance=RequestContext(request)) #response.set_cookie('num_info_%s' % eventId,'%s' % (number),max_age=3600*24*30 ) return response else: return render_to_response( 'base_error.html', { 'city': city_name, 'city_py': title, 'error_msg': u'下订单时遇到错误,请重新下单%s%s%s' % (flg, number, totalpay) }, context_instance=RequestContext(request)) return render_to_response('base_error.html', { 'city': city_name, 'city_py': title, 'error_msg': u'下订单时遇到错误,请重新下单' }, context_instance=RequestContext(request))
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
def jiabin_info(jiabin_id, new=False): mid_dct = cache.get('jiabin_info_%s' % jiabin_id) if new or not mid_dct: try: ji = models.jiabin_m.objects.get(pk=int(jiabin_id)) except: return {} mid_dct = {} dang = [] mid_dct['cat_name'] = ji.cat mid_dct['jiabin_name'] = ji.username mid_dct['jiabin_intro'] = ji.introduce mid_dct['jiabin_pic'] = ji.imgs if ji.imgs else None mid_dct['jiabin_company'] = ji.company mid_dct['jiabin_position'] = ji.position mid_dct['user_id'] = ji.id mid_dct['title'] = [] for ev in ji.jiabin_id.all().order_by("-order"): try: mid_dct['title'].append(NewformatEvent(ev)) except: pass mid_dct['picurl'] = ji.picurl mid_dct['jiabin_more'] = '/jiabin/jiabin_cat_list_index/' + str( ji.cat) + '/' + str(1) + '/' try: if ji.jiabin_id[0].begin_time > datetime.datetime.now(): mid_dct['time_now'] = u'有档期' elif ji.jiabin_id[0].begin_time > datetime.datetime.now( ) and ji.jiabin_id[0].end_time < ji.jiabin_id[0].begin_time: mid_dct['time_now'] = u'正在演讲' elif ji.jiabin_id[0].begin_time > datetime.datetime.now( ) and ji.jiabin_id[0].begin_time < datetime.date.today( ) + datetime.timedelta(-7): mid_dct['time_now'] = u'即将演讲' else: mid_dct['time_now'] = u'无档期' if mid_dct['time_now'] == u'有档期': dang.append(u'有档期') elif mid_dct['time_now'] == u'正在演讲': dang.append(u'正在演讲') elif mid_dct['time_now'] == u'即将演讲': dang.append(u'即将演讲') elif mid_dct['time_now'] == u'无档期': dang.append(u'无档期') try: mid_dct[ 'old_event_guest'] = ji.jiabin_id if ji.jiabin_id else None except: mid_dct['old_event_guest'] = None except: pass if u'有档期' in dang: mid_dct['time_now'] = u'有档期' elif '有档期' not in dang and u'无档期' in dang: mid_dct['time_now'] = u'无档期' mid_dct['guest_invitation_url'] = '/jiabin/guest_invitation/' + str( ji.id) + '/' cache.set('jiabin_info_%s' % jiabin_id, mid_dct, 3600 * 30) return mid_dct