コード例 #1
0
ファイル: profile_handler.py プロジェクト: ratana168/eventm
class UploadProfileGalleryHandler(blobstore_handlers.BlobstoreUploadHandler, webapp2.RequestHandler):
  
  mediaDao =  DaoFactory.create_ro_mediaDao()
  
  def post(self):
    upload_files = self.get_uploads('gallery_images')
    id = self.request.get("user_id")
    user = User.get_by_id(long(id))
    redirect_url = self.uri_for('profile')
    logger.info('Uploaded files: ' + str(upload_files))
    #logger.info('Get Request: ' + str(self.request.get()))
    if upload_files is not None and len(upload_files) > 0:
      files_count = len(upload_files)
      logger.info('no of files uploaded ' + str(files_count))
      for x in xrange(files_count):
        blob_info = upload_files[x]
        media_obj = Media()
        #media_obj.name = self.form.media.__getitem__(x).data['name']
        media_obj.type = constants.PHOTO
        media_obj.status = True
        #media_obj.primary = self.form.media.__getitem__(x).data['primary']
        media_obj.link = blob_info.key()
        media_obj.url = images.get_serving_url(blob_info.key())
        media_obj.entity_id = user.key
        media_obj.entity_type = constants.PROFILE
        logger.info('Upload file detail: ' + str(media_obj))
        #self.mediaDao.persist(media_obj)
        media_obj.put()
        logger.info('Link to picture file ' + images.get_serving_url(media_obj.link))
    return self.redirect(redirect_url)
コード例 #2
0
class ViewTeamHandler(blobstore_handlers.BlobstoreUploadHandler, BaseHandler):
  
  teamDao = DaoFactory.create_rw_teamDao()
  playerDao = DaoFactory.create_rw_playerDao()
  profileDao = DaoFactory.create_rw_profileDao()
  mediaDao =  DaoFactory.create_ro_mediaDao()
  eventDao =  DaoFactory.create_rw_eventDao()
  
  @user_required
  def get(self, team_id=None):
    params = {}
    
    params['players'] = self.profileDao.query_by_all(self.user_info)
    if team_id is not None and len(team_id) > 1:
      team_info = self.teamDao.get_record(long(team_id))                  
      logger.debug('team_info : ' + str(team_info))
      #if team_info.logo:
        #params['team_logo'] = images.get_serving_url(team_info.logo)                 
      if team_info.players:
        players = []
        sel_players = []
        #for player in team_info.players:
        for x in xrange(len(team_info.players)):          
          players.append(self.profileDao.get_record(long(team_info.players[x].id())))
          sel_players.append(team_info.players[x].id())                
        logger.debug('team_players : ' + str(players))
        params['team_players'] = players
        params['sel_players'] = sel_players
        
      if team_info.owners:
        owners = []
        for owner in team_info.owners:            
          owners.append(self.user_model.get_by_id(long(owner.id())))
        params['team_owners'] = owners
        logger.debug('team_owners : ' + str(owners))
      
      params['user_info'] = self.user_info
      params['team_info'] = team_info
      params['title'] = str(team_info.name) + ' Team'
      upload_url = self.uri_for('edit-team-logo')
      params['media_upload_url'] = blobstore.create_upload_url(upload_url)
      upload_gallery_url = self.uri_for('upload-team-gallery')
      params['upload_gallery_url'] = blobstore.create_upload_url(upload_gallery_url)
      params['team_gallery'] = self.mediaDao.get_all_media(team_info.key, constants.TEAM)
      recommend_events = self.eventDao.get_recommend(self.user_info.locality, self.user_info.sport, 4)
      params['recommend_events'] = recommend_events
      event_media = self.mediaDao.get_primary_media(recommend_events, constants.EVENT)
      params['event_media'] = event_media
      
      return self.render_template('/cms/team_detail.html', **params)
  
  @webapp2.cached_property
  def form(self):
    return forms.TeamForm(self) 
コード例 #3
0
ファイル: details_handler.py プロジェクト: ratana168/eventm
class TrainingCentreDetailsHandler(BaseHandler):

  trainingcentreDao =  DaoFactory.create_ro_trainingCentreDao()  
  mediaDao =  DaoFactory.create_ro_mediaDao()
  
  def get(self, city_name, locality_name, entity_id, entity_alias):
    logger.debug('Training Centre details for city %s, locality %s, id %s, alias %s ' % (city_name, locality_name, entity_id, entity_alias))
    if self.request.query_string != '':
      query_string = '?' + self.request.query_string
    else:
      query_string = ''
    continue_url = self.request.path_url + query_string
    
    if entity_id is None:
      message = ('Invalid Training Centre ID.')
      self.add_message(message, 'warning')
      self.redirect_to('home')
    else:
      tc = self.trainingcentreDao.get_record(entity_id)      
      if tc is None:
        message = ('Training Centre could not be retrieved.')
        self.add_message(message, 'warning')
        return
      else:
        params = {}
        params['tc'] = tc
        params['types'] = constants.TRAINING_CENTRE
        params['sport'] = tc.sport
        params['city_name'] = tc.address.city
        params['locality_name'] = tc.address.locality
        params['media'] = self.mediaDao.get_active_media(tc.key, tc.sport, constants.TRAINING_CENTRE)
        params['continue_url'] = continue_url
        params['upload_cover_url'] = blobstore.create_upload_url(self.uri_for('upload-trainingcentre-cover', **{'continue': continue_url}))
        params['enquire_url'] = self.uri_for('enquire-trainingcentre', **{'continue': continue_url})
        params['title'] = tc.name        
        all_media = self.mediaDao.get_all_media(tc.key, constants.TRAINING_CENTRE)
        current_media = []
        for photo in all_media:
          current_media.append({'name': photo.name, 'url':images.get_serving_url(photo.link), 'status': photo.status, 'primary': photo.primary})
        params['current_media'] = current_media
        if tc.cover:
          params['tc_cover'] = images.get_serving_url(tc.cover)
          
        return self.render_template('/app/tc_details1.html', **params)
コード例 #4
0
ファイル: details_handler.py プロジェクト: ratana168/eventm
class PlaygroundDetailsHandler(BaseHandler):

  playgroundDao =  DaoFactory.create_ro_playgroundDao()
  mediaDao =  DaoFactory.create_ro_mediaDao()
  
  def get(self, city_name, locality_name, entity_id, entity_alias):
    logger.debug('Playground details for city %s, locality %s, id %s, alias %s ' % (city_name, locality_name, entity_id, entity_alias))
    if self.request.query_string != '':
      query_string = '?' + self.request.query_string
    else:
      query_string = ''
    continue_url = self.request.path_url + query_string
    
    if entity_id is None:
      message = ('Invalid Playground ID.')
      self.add_message(message, 'warning')
      self.redirect_to('home')
    else:
      playground = self.playgroundDao.get_record(entity_id)
      if playground is None:
        message = ('Playground could not be retrieved.')
        self.add_message(message, 'warning')
        self.redirect_to('home')
      else:
        params = {}
        params['playground'] = playground
        params['types'] = constants.PLAYGROUND
        params['sport'] = playground.sport
        params['city_name'] = playground.address.city
        params['locality_name'] = playground.address.locality
        params['media'] = self.mediaDao.get_active_media(playground.key, playground.sport, constants.PLAYGROUND)
        params['continue_url'] = continue_url
        params['upload_cover_url'] = blobstore.create_upload_url(self.uri_for('upload-playground-cover', **{'continue': continue_url}))
        params['enquire_url'] = self.uri_for('enquire-playground', **{'continue': continue_url})
        params['title'] = playground.name
        all_media = self.mediaDao.get_all_media(playground.key, constants.PLAYGROUND)
        current_media = []
        for photo in all_media:
          current_media.append({'name': photo.name, 'url':images.get_serving_url(photo.link), 'status': photo.status, 'primary': photo.primary})
        params['current_media'] = current_media
        if playground.cover:
          params['pg_cover'] = images.get_serving_url(playground.cover)
        return self.render_template('/app/pg_details1.html', **params)
コード例 #5
0
class CityHomeHandler(BaseHandler):

  mediaDao =  DaoFactory.create_ro_mediaDao()
  eventDao =  DaoFactory.create_ro_eventDao()
  playgroundDao =  DaoFactory.create_ro_playgroundDao()
  trainingcentreDao =  DaoFactory.create_ro_trainingCentreDao()  

  def get(self, city_name=None, sport=None):
    params = {}
    logger.debug('home for city %s, and sport %s ' % (city_name, sport))
    # if city_name is None:
    #   city_name = get_default_city()
    # if sport is not None and sport != 'None' and sport != '':
    #     return self.render_template('/cms/dashboard.html')
    recent_playgrounds = self.playgroundDao.get_recent(city_name, sport)  
    featured_playgrounds = self.playgroundDao.get_featured(city_name, sport)
    popular_playgrounds = self.playgroundDao.get_popular(city_name, sport)
    logger.debug(' recent_playgrounds %s ' % len(recent_playgrounds))
    logger.debug(' featured_playgrounds %s ' % len(featured_playgrounds))
    logger.debug(' popular_playgrounds %s ' % len(popular_playgrounds))
    playgrounds = recent_playgrounds + featured_playgrounds + popular_playgrounds
    playground_media = self.mediaDao.get_primary_media(playgrounds, constants.PLAYGROUND)
    logger.debug(' playground_media %s ' % len(playground_media))
    
    recent_trainingcentres = self.trainingcentreDao.get_recent(city_name, sport)
    featured_trainingcentres = self.trainingcentreDao.get_featured(city_name, sport) 
    popular_trainingcentres = self.trainingcentreDao.get_popular(city_name, sport)
    logger.debug(' recent_trainingcentres %s ' % len(recent_trainingcentres))
    logger.debug(' featured_trainingcentres %s ' % len(featured_trainingcentres))
    logger.debug(' popular_trainingcentres %s ' % len(popular_trainingcentres))
    trainingcentres = recent_trainingcentres + featured_trainingcentres + popular_trainingcentres
    trainingcentre_media = self.mediaDao.get_primary_media(trainingcentres, constants.TRAINING_CENTRE)
    logger.debug(' trainingcentre_media %s ' % len(trainingcentre_media))
    
    recent_events = self.eventDao.get_recent(city_name, sport)
    featured_events = self.eventDao.get_featured(city_name, sport)
    ongoing_events = self.eventDao.get_ongoing(city_name, sport)
    upcoming_events = self.eventDao.get_upcoming(city_name, sport)
    logger.debug(' recent_events %s ' % len(recent_events))
    logger.debug(' featured_events %s ' % len(featured_events))
    logger.debug(' ongoing_events %s ' % len(ongoing_events))
    logger.debug(' upcoming_events %s ' % len(upcoming_events))
    events = recent_events + featured_events + ongoing_events + upcoming_events
    event_media = self.mediaDao.get_primary_media(events, constants.EVENT)
    logger.debug(' event_media %s ' % len(event_media))
    
    params['recent_playgrounds'] = recent_playgrounds
    params['featured_playgrounds'] = featured_playgrounds
    params['popular_playgrounds'] = popular_playgrounds
    params['playground_media'] = playground_media
    
    params['recent_events'] = recent_events
    params['featured_events'] = featured_events
    params['ongoing_events'] = ongoing_events
    params['upcoming_events'] = upcoming_events
    params['event_media'] = event_media
    
    params['recent_trainingcentres'] = recent_trainingcentres
    params['featured_trainingcentres'] = featured_trainingcentres
    params['popular_trainingcentres'] = popular_trainingcentres
    params['trainingcentre_media'] = trainingcentre_media 

    if city_name is None:
        city_name = get_default_city()
    
    params['city_name'] = city_name
    params['sport'] = sport
    params['home'] = 'true'
    params['title'] = 'Sports Home'
    
    return self.render_template('/app/homenew.html', **params)
コード例 #6
0
ファイル: search_handler.py プロジェクト: ratana168/eventm
class PlaygroundSearchHandler(BaseHandler):

    playgroundDao = DaoFactory.create_rw_playgroundDao()
    mediaDao = DaoFactory.create_ro_mediaDao()
    importDao = DaoFactory.create_rw_importDao()

    def get(self, city_name=None, locality_name=None):
        return self.post(city_name, locality_name)

    def post(self, city_name=None, locality_name=None):
        city_str = str(self.request.get('city-name'))
        locality_nav = str(self.request.get('nav-locality'))
        locality_home = str(self.request.get('pg-locality'))
        locality_str = locality_nav if locality_nav != '' else locality_home
        locality_id_nav = str(self.request.get('nav-locality_id'))
        locality_id_home = str(self.request.get('pg-locality_id'))
        locality_id_str = locality_id_nav if locality_id_nav != '' else locality_id_home

        name = str(self.request.get('name'))
        sport = str(self.request.get('sport'))
        pg_sport = str(self.request.get('pg-sport'))
        sport = pg_sport if pg_sport != '' and pg_sport != 'None' else sport
        city = city_name if city_name is not None else city_str
        locality = locality_name if locality_name is not None else locality_str
        logger.debug('playground search :: city %s, sport %s, locality %s' %
                     (city, sport, locality))

        nav_type_str = str(self.request.get('nav'))
        nav_type = nav_type_str if nav_type_str != '' and nav_type_str != 'None' else None
        curs_str = str(self.request.get('page'))
        curs = curs_str if curs_str != '' and curs_str != 'None' else None
        remote_ip = self.request.remote_addr

        params = {}
        search_params = {}
        playgrounds = []
        playground_list = []
        playground_media = []

        if name != '' and name != 'None':
            search_params['name'] = name
        if sport != '' and sport != 'None':
            search_params['sport'] = sport
        if city != '' and city != 'None':
            params['city_name'] = city
            search_params['address.city'] = city
        if locality != '' and locality != 'None' and locality != 'all':
            search_params['address.locality'] = locality
            #logger.debug('Search Params : ' + str(search_params))

        page_id = 1
        if curs is not None:
            page_id = int(curs)
        else:
            playground_search = self.playgroundDao.search_index(
                remote_ip, 'approved', **search_params)

        playground_keys = self.playgroundDao.get_search_keys(
            constants.PLAYGROUND + '_' + str(remote_ip))

        total_entries = len(playground_keys)
        logger.debug('NO of playgrounds matched the search %s ' %
                     total_entries)

        if total_entries > 0:
            total_pages = (total_entries / PAGE_SIZE) + 1
            params['page_range'] = range(1, total_pages + 1)

            offset = (page_id * PAGE_SIZE) - PAGE_SIZE
            limit = offset + PAGE_SIZE
            playground_list = playground_keys[offset:limit]
            playgrounds = ndb.get_multi(playground_list)
            playground_media = self.mediaDao.get_primary_media(
                playgrounds, constants.PLAYGROUND)
            logger.debug('Displayed Page No.%s Playgrounds from %s to %s' %
                         (page_id, offset + 1, limit))

        suggest_params = {}
        if len(playground_keys) < PAGE_SIZE and (locality_id_str != ''
                                                 or locality != ''
                                                 or curs is not None):
            suggest_playground_keys = []
            if curs is None:
                if locality_id_str != '':
                    locality_data = self.importDao.query_by_place_id(
                        locality_id_str)
                elif locality != '':
                    locality_data = self.importDao.query_by_place_name(
                        locality.title())

                if locality_data:
                    suggest_params['latlong'] = locality_data.latlong
                    suggest_params['address.locality'] = locality_data.name
                    suggest_playground_keys = self.playgroundDao.search_index_suggest(
                        remote_ip, 'approved', **suggest_params)
            else:
                suggest_playground_keys = self.playgroundDao.get_suggest_keys(
                    'suggest_' + str(constants.PLAYGROUND) + '_' +
                    str(remote_ip))

            if suggest_playground_keys is not None:
                suggest_playgrounds = ndb.get_multi(suggest_playground_keys)
                params['suggest_playgrounds'] = suggest_playgrounds
                logger.debug('No of Suggested Search Result : %s' %
                             len(suggest_playground_keys))
                #logger.debug('Suggested Search Result keys : ' + str(suggest_playground_keys))
                suggest_playground_media = self.mediaDao.get_primary_media(
                    suggest_playgrounds, constants.PLAYGROUND)
                #logger.debug('Suggest Media: ' + str(suggest_playground_media))
                if len(suggest_playground_media) > 0:
                    if len(playground_media) > 0:
                        playground_media.update(suggest_playground_media)
                    else:
                        playground_media = suggest_playground_media

        params['types'] = constants.PLAYGROUND
        params['sport'] = sport
        params['locality_name'] = locality
        params['playgrounds'] = playgrounds
        params['playground_media'] = playground_media
        params['title'] = constants.PLAYGROUND
        logger.debug('Param Results: ' + str(params))
        return self.render_template('/app/search_results.html', **params)
コード例 #7
0
ファイル: search_handler.py プロジェクト: ratana168/eventm
class EventSearchHandler(BaseHandler):

    eventDao = DaoFactory.create_rw_eventDao()
    mediaDao = DaoFactory.create_ro_mediaDao()

    def get(self, city_name=None, locality_name=None):
        return self.post(city_name, locality_name)

    def post(self, city_name=None, locality_name=None):
        city_str = str(self.request.get('city-name'))
        sport = str(self.request.get('sport'))
        #locality_str = str(self.request.get('se-locality'))
        locality_nav = str(self.request.get('nav-locality'))
        locality_home = str(self.request.get('se-locality'))
        locality_str = locality_nav if locality_nav != '' else locality_home
        #logger.debug('sporting event search :: locality_nav %s, locality_home %s, locality_str %s' % (locality_nav, locality_home, locality_str))

        se_sport = str(self.request.get('se-sport'))
        sport = se_sport if se_sport != '' and se_sport != 'None' else sport
        city = city_name if city_name is not None else city_str
        locality = locality_name if locality_name is not None else locality_str
        logger.debug(
            'sporting event search :: city %s, sport %s, locality %s' %
            (city, sport, locality))

        recent_events = self.eventDao.get_recent(city, sport, locality, -1)
        ongoing_events = self.eventDao.get_ongoing(city, sport, locality, -1)
        ongoing_events_future = self.eventDao.get_ongoing_future(
            city, sport, locality, -1)
        future_events = self.eventDao.get_upcoming(city, sport, locality, -1)
        logger.debug(' recent_events %s ' % len(recent_events))
        logger.debug(' future_events %s ' % len(future_events))
        logger.debug(' ongoing_events %s ' % len(ongoing_events))
        logger.debug(' ongoing_events_future %s ' % len(ongoing_events_future))

        ongoing_upcoming_events = []
        ongoing_upcoming_events = [
            val for val in ongoing_events if val in ongoing_events_future
        ]
        logger.debug(' ongoing_upcoming_events %s ' %
                     len(ongoing_upcoming_events))

        for event in future_events:
            ongoing_upcoming_events.append(event)
        #for event in ongoing_events:
        #ongoing_upcoming_events.append(event)

        temp_events = []
        for event in recent_events:
            temp_events.append(event)
        for event in ongoing_upcoming_events:
            temp_events.append(event)

        event_media = self.mediaDao.get_primary_media(temp_events,
                                                      constants.EVENT)
        logger.debug(' event_media %s ' % len(event_media))

        params = {}
        params['types'] = constants.EVENT
        params['sport'] = sport
        params['locality_name'] = locality
        if city != '' and city != 'None':
            params['city_name'] = city

        params['recent_events'] = recent_events
        params['future_events'] = ongoing_upcoming_events
        logger.debug(' future_events %s ' % len(ongoing_upcoming_events))
        params['event_media'] = event_media
        params['title'] = constants.EVENT
        #logger.debug('Params to template ' + str(params))

        return self.render_template('/app/events_home.html', **params)
コード例 #8
0
ファイル: details_handler.py プロジェクト: ratana168/eventm
class EventDetailsHandler(BaseHandler):

  eventDao =  DaoFactory.create_ro_eventDao()
  mediaDao =  DaoFactory.create_ro_mediaDao()
  matchDao = DaoFactory.create_ro_matchDao()
  teamDao = DaoFactory.create_rw_teamDao()
  registerDao = DaoFactory.create_rw_registerDao()  
  
  def get(self, city_name, entity_id, entity_alias):
    logger.debug('Event details for city %s, id %s, alias %s ' % (city_name, entity_id, entity_alias))
    if self.request.query_string != '':
      query_string = '?' + self.request.query_string
    else:
      query_string = ''
    continue_url = self.request.path_url + query_string
    
    if entity_id is None:
      message = ('Invalid Event ID.')
      self.add_message(message, 'warning')
      self.redirect_to('home')
    else:
      event = self.eventDao.get_record(entity_id)
      if event is None:
        message = ('Event could not be retrieved.')
        self.add_message(message, 'warning')
        return
      else:
        past_events = []
        future_events = []
        other_events = self.eventDao.get_business_events(event.business_id)
        if other_events and len(other_events) > 0:
          for other_event in other_events:
            if other_event.key.id() != event.key.id(): 
              if get_event_state(other_event) == 'past':
                past_events.append(other_event)
              else:
                future_events.append(other_event)
                 
        event_media = self.mediaDao.get_primary_media(other_events, constants.EVENT)
                 
        params = {}        
        params['event'] = event
        params['types'] = constants.EVENT
        params['sport'] = event.sport
        params['city_name'] = event.address.city
        params['locality_name'] = event.address.locality
        params['past_events'] = past_events if len(past_events) > 0 else None 
        params['future_events'] = future_events if len(future_events) > 0 else None
        params['event_media'] = event_media
        params['media'] = self.mediaDao.get_active_media(event.key, event.sport, constants.EVENT)
        params['matches'] = self.matchDao.get_matches_for_event(event.key, self.user_info)
        params['continue_url'] = continue_url
        params['event_state'] = get_event_state(event)
        params['title'] = event.name
        
        if self.user_info:
          register_url = self.uri_for('event-register')
          params['teams'] = self.teamDao.query_by_owner(self.user_info)
          event_reg = self.registerDao.query_by_reg_user_id(event.key, self.user_info)
          logger.info('Event Registered Details: ' + str(event_reg))
          
          if event_reg:
            params['reg_type'] = event_reg.reg_type
            register_url = self.uri_for('edit-event-register', record_id = event_reg.key.id(), **{'continue': continue_url})            
            if event_reg.team_id:
              params['reg_teams'] = [x.id() for x in event_reg.team_id]
              logger.info('Event Registered Teams : ' + str(params['reg_teams']))
            if event_reg.player_id:
              params['reg_players'] = [x.id() for x in event_reg.player_id]
              logger.info('Event Registered Players : ' + str(params['reg_players']))
          params['register_url'] = register_url
          
        if event.sport == "cricket":
          return self.render_template('/app/event_details_cricket.html', **params)
        else:
          return self.render_template('/app/event_details.html', **params)
コード例 #9
0
ファイル: profile_handler.py プロジェクト: ratana168/eventm
class ProfileHandler(blobstore_handlers.BlobstoreUploadHandler, BaseHandler):
  
  eventDao =  DaoFactory.create_rw_eventDao() 
  playgroundDao =  DaoFactory.create_rw_playgroundDao()   
  trainingcentreDao =  DaoFactory.create_rw_trainingCentreDao() 
  mediaDao =  DaoFactory.create_ro_mediaDao()
  profileDao =  DaoFactory.create_rw_profileDao()
  teamDao =  DaoFactory.create_rw_teamDao()
  
  @user_required
  def get(self, user_id=None):
    params = {}
    
    if user_id is not None  and len(user_id) > 1:
      user_info = self.user_model.get_by_id(long(user_id))
      upload_url = self.uri_for('edit-profile', user_id=user_id)            
      logger.debug('upload_url : ' + upload_url)
      if user_info.image:
        params['current_image'] = images.get_serving_url(user_info.image)
      if user_info.sport:
        params['sel_sport'] = [x.strip() for x in user_info.sport.split(',')]
      params['sports_list'] = constants.SPORTS_LIST
      params['media_upload_url'] = blobstore.create_upload_url(upload_url)      
      
      self.form = forms.UserProfileForm(self, user_info)
      return self.render_template('/cms/edit_profile.html', **params)
    
    '''logger.debug('User Id: ' + str(self.user_id))
    logger.debug('User Info: ' + str(self.user_info))
    logger.debug('User Type: ' + str(self.user_type))'''
    if self.user_info.image:
      params['current_image'] = images.get_serving_url(self.user_info.image)
    elif self.user_type[0] == 'facebook':
      params['current_image'] = 'https://graph.facebook.com/'+str(self.user_type[1])+'/picture?type=large'
    upload_url = self.uri_for('edit-user-image')
    params['media_upload_url'] = blobstore.create_upload_url(upload_url)
    upload_gallery_url = self.uri_for('upload-profile-gallery')
    params['upload_gallery_url'] = blobstore.create_upload_url(upload_gallery_url)
    params['title'] = self.user_info.name
    params['want_list'] = constants.WANT_DICT
    params['owner_info'] = self.user_info
    params['profile_gallery'] = self.mediaDao.get_all_media(self.user_info.key, constants.PROFILE)    
    params['owner_playgrounds'] = self.playgroundDao.query_by_owner(self.user_info)
    params['owner_events'] = self.eventDao.query_by_owner(self.user_info)    
    params['owner_trainingcentres'] = self.trainingcentreDao.query_by_owner(self.user_info)
    params['owner_teams'] = self.teamDao.query_by_owner(self.user_info, 'all', 4)
    
    recommend_events = self.eventDao.get_recommend(self.user_info.locality, self.user_info.sport, 4)
    params['recommend_events'] = recommend_events
    recommend_playgrounds = self.playgroundDao.get_recommend(self.user_info.locality, self.user_info.sport, 4)
    params['recommend_playgrounds'] = recommend_playgrounds    
    recommend_trainingcentres = self.trainingcentreDao.get_recommend(self.user_info.locality, self.user_info.sport, 4)
    params['recommend_trainingcentres'] = recommend_trainingcentres
        
    event_media = self.mediaDao.get_primary_media(recommend_events, constants.EVENT)
    params['event_media'] = event_media
    playground_media = self.mediaDao.get_primary_media(recommend_playgrounds, constants.PLAYGROUND)
    params['playground_media'] = playground_media
    trainingcentre_media = self.mediaDao.get_primary_media(recommend_trainingcentres, constants.TRAINING_CENTRE)
    params['trainingcentre_media'] = trainingcentre_media
    logger.debug(' event_media %s ' % len(event_media))
    logger.debug(' playground_media %s ' % len(playground_media))
    logger.debug(' trainingcentre_media %s ' % len(trainingcentre_media))
    
    return self.render_template('/cms/profile.html', **params)