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

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

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


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

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

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

        if event.has_key('cf'):
            body['cf']=event['cf']
        return render_to_response(template_name,body,context_instance=RequestContext(request))
示例#2
0
文件: views.py 项目: sureboy/xiaorizi
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))
示例#3
0
def showPage(request,query=False,template_name='m_event.html'): 
    event={}
    if query.isdigit():
        event= NewformatEvent(False,int(query),request.GET.get('new',False))        
 
    if not event.has_key('isshow'):
        return render_to_response('not.html',{'error_msg':u'没有该活动  '  })
  
    else:
        if not event['isshow'] in [1,8]:
            return render_to_response('not.html',{'error_msg':u'活动没有发布' })       

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

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


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

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

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

        if event.has_key('cf'):
            body['cf']=event['cf']
        return render_to_response(template_name,body,context_instance=RequestContext(request))
示例#4
0
文件: views.py 项目: sureboy/xiaorizi
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))