Ejemplo n.º 1
0
def showQ(request,query=False,template_name='q_showEvent.html'):
    event={}
    if query.isdigit():
        event= NewAppEvent(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))
Ejemplo n.º 2
0
def showQ(request, query=False, template_name='q_showEvent.html'):
    event = {}
    if query.isdigit():
        event = NewAppEvent(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))
Ejemplo n.º 3
0
 def getevent(self,id=None,new=False):
     if not id:
         return {}
     
     event={}
     ca=NewAppEvent(None,id,new)
     #print ca
     event['id']=ca['event_id']
     #event['isurl']=True if ca['isshow']==8 else False
     event['title']=ca['title']
     event['imgs']=ca['img_s']
     event['cat']={'name':ca['cat_name'] if ca['cat_name'] else '',
                   'id':ca['catid'] if ca['catid'] else '',
                   'img':ca['cat_img']['img']  if ca['cat_img'] else ''
                   }
     
     #event['cat_name']=ca['cat_name'] if ca['cat_name'] else ''
     #event['catid']=ca['catid'] if ca['catid'] else ''
     #event['cat_img']=ca['cat_img'] if ca['cat_img'] else ''
     
     if ca.has_key('feeltitle'):
         event['feeltitle']=ca['feeltitle'] if ca['feeltitle'] else ''
     else:
         event['feeltitle']=''
     event['mobileURL']='http://m.huodongjia.com/app-%s.html'%ca['event_id']
     event['questionURL']='http://m.huodongjia.com/q-%s.html'%ca['event_id']
     event['shareURL']='http://m.huodongjia.com/share-%s.html'%ca['event_id']
     #des1 = ''.join(BeautifulSoup(ca['des']).findAll(text=True))
     #des1 = ''.join(replaceCharEntity(des1))    
 
 
     event['tag']=','.join(ca['event_tag'])
     event['price']=ca['app_price']
     
     event['feel']=ca['feel']
     event['feelnum']=ca['feelnum'] if ca['feelnum'] else 0
     event['address']=ca['event_address']
     event['position']=ca['position']
     event['startdate']=ca['startdate']
     event['enddate']=ca['enddate']
     event['islongtime']=ca['event_islongtime']
     event['city']=ca['district_name']
     
     event['detail']=''
     try:
         event['detail']=ca['detail']  
     except:
         pass
     if not event['detail']:        
         event['detail']=ca['des']
         
     if not event['detail']:         
         i=1            
         str_h=  str_html(ca['event_content'][0][1]) 
         
         for de in str_h.split('\n'):
             if event['detail']:
                 event['detail']+='\r\n'
             
             te= BeautifulSoup(de).text
             if te and len(te)>15:            
                 i+=1
     
                 event['detail'] += '%s' % te
             if i>3:
                 break
     
         event['detail']=event['detail'].replace('\r\n\r\n','\r\n')\
                 .replace('\n\n\n\n','\r\n').replace('\n\n\n','\r\n').replace('\n\n','\r\n')
     #event['detail']= BeautifulSoup(ca['event_content'][0][1]).text[0:250]
   
     
 
     for con in ca['event_content']:
         if con[0] in [u'购买须知']:
             event['note']=con[1]
             break
 
     try:
         event['note']=str_html(event['note']).replace('\r\n','')
         event['note']=BeautifulSoup(event['note']).text
         o=event['note'].find(u'。')
         if o>0:
             event['note']=event['note'][:o]
         else:
             no=event['note'].split(u',')
             if len(no)>2:
                 event['note']='%s%s' % (u','.join(no[:2]),'...')
     except:
         event['note']=''    
         
     event['comment']={}
     try:        
         com=UserEventMessage.objects.filter(event_id=ca['event_id']).order_by('id')[0]
         event['comment']['id']=com.id
         event['comment']['content']=com.message.txt
         event['comment']['date']=time.mktime(com.end_time.timetuple())
         
         event['comment']['score']=0
         event['comment']['imgs']=[]
         event['comment']['user']={'id':com.user.user_id,'name':com.user.user_name}
 
     except:
         pass
     event['commentTotol']={}
     
     event['more']=[]
     for ev in event_city_cat(ca['district_id']):
         if ev!=event['id']:
             
             e=NewAppEvent(None,ev)
             even={'id':e['event_id'],'title':e['title'],'price':e['app_price'],'imgs':e['img_s']}
             event['more'].append(even)
             
         if len(event['more'])>4:
             break
     
     return event
Ejemplo n.º 4
0
    def getevent(self, id=None, new=False):
        if not id:
            return {}

        event = {}
        ca = NewAppEvent(None, id, new)
        #print ca
        event['eid'] = ca['id']
        event['id'] = ca['event_id']
        #event['isurl']=True if ca['isshow']==8 else False
        event['title'] = ca['title']
        event['imgs'] = ca['img_s']
        event['cat'] = {
            'name': ca['cat_name'] if ca['cat_name'] else '',
            'id': ca['catid'] if ca['catid'] else '',
            'img': ca['cat_img']['img'] if ca['cat_img'] else ''
        }

        #event['cat_name']=ca['cat_name'] if ca['cat_name'] else ''
        #event['catid']=ca['catid'] if ca['catid'] else ''
        #event['cat_img']=ca['cat_img'] if ca['cat_img'] else ''

        if ca.has_key('feeltitle'):
            event['feeltitle'] = ca['feeltitle'] if ca['feeltitle'] else ''
        else:
            event['feeltitle'] = ''

        event['mobileURL'] = 'http://life.huodongjia.com/app/app-%s.html' % ca[
            'event_id']
        event['questionURL'] = 'http://life.huodongjia.com/app/q-%s.html' % ca[
            'event_id']
        event[
            'shareURL'] = 'http://life.huodongjia.com/app/share-%s.html' % ca[
                'event_id']
        #des1 = ''.join(BeautifulSoup(ca['des']).findAll(text=True))
        #des1 = ''.join(replaceCharEntity(des1))

        event['tag'] = ','.join(ca['event_tag'])
        event['price'] = ca['app_price']

        event['feel'] = ca['feel']
        event['feelnum'] = ca['feelnum'] if ca['feelnum'] else 0

        event['address'] = ca['event_address'] if ca['event_address'] else ca[
            'event_venue']
        event['position'] = ca['position']
        event['startdate'] = ca['startdate']
        event['enddate'] = ca['enddate']
        event['islongtime'] = ca['event_islongtime']
        event['city'] = ca['district_name']

        event['detail'] = ''
        try:
            event['detail'] = ca['detail']
        except:
            pass
        if not event['detail']:
            event['detail'] = ca['des']

        if not event['detail']:
            i = 1
            try:
                str_h = str_html(ca['event_content'][0][1])
            except:
                str_h = ''

            for de in str_h.split('\n'):
                if event['detail']:
                    event['detail'] += '\r\n'

                te = BeautifulSoup(de).text
                if te and len(te) > 15:
                    i += 1

                    event['detail'] += '%s' % te
                if i > 3:
                    break

            event['detail']=event['detail'].replace('\r\n\r\n','\r\n')\
                    .replace('\n\n\n\n','\r\n').replace('\n\n\n','\r\n').replace('\n\n','\r\n')
        #event['detail']= BeautifulSoup(ca['event_content'][0][1]).text[0:250]

        for con in ca['event_content']:
            if con[0] in [u'购买须知']:
                event['note'] = con[1]
                break

        try:
            event['note'] = str_html(event['note']).replace('\r\n', '')
            event['note'] = BeautifulSoup(event['note']).text
            o = event['note'].find(u'。')
            if o > 0:
                event['note'] = event['note'][:o]
            else:
                no = event['note'].split(u',')
                if len(no) > 2:
                    event['note'] = '%s%s' % (u','.join(no[:2]), '...')
        except:
            event['note'] = ''

        event['comment'] = {}
        try:
            com = UserEventMessage.objects.filter(
                event_id=ca['event_id']).order_by('id')[0]
            event['comment']['id'] = com.id
            event['comment']['content'] = com.message.txt
            event['comment']['date'] = time.mktime(com.end_time.timetuple())

            event['comment']['score'] = 0
            event['comment']['imgs'] = []
            event['comment']['user'] = {
                'id': com.user.user_id,
                'name': com.user.user_name
            }

        except:
            pass
        event['commentTotol'] = {}

        event['more'] = self.more(event['id'], ca['district_id'], new)

        return event
Ejemplo n.º 5
0
    def getevent_2_0(self,id=None,new=False):
        if not id:
            return {}
        
        event={}
        ca=NewAppEvent(None,id,new)
        #print ca
        event['eid']=ca['id']
        event['id']=ca['event_id']
        event['isurl']=True if ca['isshow']==8 else False
        event['title']=ca['title']
        event['imgs']=ca['img_s']
        event['adurl']=ca['event_img']
        event['sponsor']=ca['sponsor'][0] if len(ca['sponsor'])>0 else {}        
        #del event['imgs'][0]
        event['cat']={'name':ca['cat_name'] if ca['cat_name'] else '',
                      'id':ca['catid'] if ca['catid'] else '',
                      'img':ca['cat_img']['img']  if ca['cat_img'] else ''
                      }
        
        #event['cat_name']=ca['cat_name'] if ca['cat_name'] else ''
        #event['catid']=ca['catid'] if ca['catid'] else ''
        #event['cat_img']=ca['cat_img'] if ca['cat_img'] else ''
        
        if ca.has_key('feeltitle'):
            event['feeltitle']=ca['feeltitle'] if ca['feeltitle'] else ''
        else:
            event['feeltitle']=''
            

        #des1 = ''.join(BeautifulSoup(ca['des']).findAll(text=True))
        #des1 = ''.join(replaceCharEntity(des1))
    
    
        event['tag']=','.join(ca['event_tag'])
        event['price']=ca['app_price']
        
        event['feel']=ca['feel']
        event['feelnum']=ca['feelnum'] if ca['feelnum'] else 0
        event['address']=ca['event_address'] if ca['event_address']  else ca['event_venue']
        event['position']=ca['position']
        event['startdate']=ca['startdate']
        event['enddate']=ca['enddate']
        event['islongtime']=ca['event_islongtime']
        event['city']=ca['district_name']
        
        event['detail']=''
        try:
            event['detail']=ca['detail']  
        except:
            pass
        if not event['detail']:        
            event['detail']=ca['des']
            
        if not event['detail']:     
            try:    
                i=1            
                str_h=  str_html(ca['event_content'][0][1]) 
                
                for de in str_h.split('\n'):
                    if event['detail']:
                        event['detail']+='\r\n'
                    
                    te= BeautifulSoup(de).text
                    if te and len(te)>15:            
                        i+=1
            
                        event['detail'] += '%s' % te
                    if i>3:
                        break
        
                event['detail']=event['detail'].replace('\r\n\r\n','\r\n')\
                        .replace('\n\n\n\n','\r\n').replace('\n\n\n','\r\n').replace('\n\n','\r\n')
            except:
                event['detail']=''
        #event['detail']= BeautifulSoup(ca['event_content'][0][1]).text[0:250]
      
        
        cont=''
        for con in ca['event_content']:
            if con[0] in [u'购买须知',u'相关介绍']:
                if con[0]==u'购买须知':
                    
                    event['note']=con[1]
                    note=event['note']
                elif con[0]==u'相关介绍':
                    cont=con[1]
                    
                #break
            
    
        try:
            event['note']=str_html(event['note']).replace('\r\n','')
            event['note']=BeautifulSoup(event['note']).text
            o=event['note'].find(u'。')
            if o>0:
                event['note']=event['note'][:o]
            else:
                no=event['note'].split(u',')
                if len(no)>2:
                    event['note']='%s%s' % (u','.join(no[:2]),'...')
        except:
            event['note']='' 
            note=''   
            
        event['comment']={}
        try:        
            com=UserEventMessage.objects.filter(event_id=ca['event_id']).order_by('id')[0]
            event['comment']['id']=com.id
            event['comment']['content']=com.message.txt
            event['comment']['date']=time.mktime(com.end_time.timetuple())
            
            event['comment']['score']=0
            event['comment']['imgs']=[]
            event['comment']['user']={'id':com.user.user_id,'name':com.user.user_name}
    
        except:
            pass
        event['commentTotol']={}
        if not cont:
            cont=ca['event_content'][0][1]
        
        #cont = cont.replace('\n','').replace('\r','').replace('<br>','').replace('<br/>','').replace('<br />','')
        cont = cont.replace('\n','').replace('\r','').replace('\r\n', '')
        try:
            #note=note.strip().replace('\n','').replace('\r','').replace('<br>','').replace('<br/>','').replace('<br />','')

            note=note.strip().replace('\n','').replace('\r','').replace(u'【', '').replace(u'】', '')
        except:
            note=''
        
        if event['isurl']:

            event['mobileURL'] = 'http://life.huodongjia.com/app/app-%s.html'%ca['event_id']
            event['questionURL']='http://life.huodongjia.com/app/q-%s.html'%ca['event_id']
        else:
            #event['mobileURL']=gettext(find_img_tag(cont)) #'http://m.huodongjia.com/app-%s.html'%ca['event_id']
            #event['questionURL']=gettext(find_img_tag(note))

            event['mobileURL'] = xml_fmt_convert(cont)
            event['questionURL'] = xml_fmt_convert(note)

        

        event['shareURL']='http://life.huodongjia.com/app/share-%s.html'%ca['event_id']
        
        event['more']=self.more(event['id'], ca['district_id'], new)
                
    
        
        return event