Exemple #1
0
 def get(self):
     user,_,url,url_linktext = self.get_user()
     
     #get filters from url
     location = helper.creatList(self.request.get("locationfilter"))
     type = helper.creatList(self.request.get("typefilter"))
     season = helper.creatList(self.request.get("seasonfilter"))
     
     #get all trips
     trips_query = Trip.query(Trip.visibility==True)
     if location != ['']:
         trips_query = trips_query.filter(Trip.trip_tags.location.IN(location))
     if type != ['']:
         trips_query = trips_query.filter(Trip.trip_tags.type.IN(type))
     if season != ['']:
         trips_query = trips_query.filter(Trip.trip_tags.season.IN(season))
 
     trips = trips_query.fetch()
     
     #create template
     template_values = {'user': user, 'url': url, 'url_linktext': url_linktext,
                       'location':location,'type':type,'season':season,'trips':trips}
     template = JINJA_ENVIRONMENT.get_template('templates/new/search.html')
  
     self.response.write(template.render(template_values))
Exemple #2
0
def get_trips_from_account_info(account_info):
    parent_key = get_parent_key(account_info.rose_username)
    trips = Trip.query(ancestor=parent_key).order(Trip.pick_up_time).fetch()
    trip_map ={}
    for trip in trips:
        trip_map[trip.key]=trip
    return trips, trip_map
Exemple #3
0
def make_track_tree(id,location,type,season):
    '''
    Create tree (http://www.ztree.me/v3/main.php#_zTreeInfo)
    '''
    #get all trips
    trips_query = Trip.query(ancestor=trip_key(id))
    if location != []:
        trips_query = trips_query.filter(Trip.trip_tags.location.IN(location))
    if type != []:
        trips_query = trips_query.filter(Trip.trip_tags.type.IN(type))
    if season != []:
        trips_query = trips_query.filter(Trip.trip_tags.season.IN(season))
    
    trips = trips_query.fetch()
      
    #create tree structure from trips
    tree = []
    i = 1
    of = 0
    tree.append({'id':0, 'pId':0, 'name':'My Trips','isParent': 'true','open':'true'})
    for trip in trips:
        tree.append({'id':i, 'pId':0, 'name':str(trip.trip_name),'isParent': 'true', 'click':"openTrip('"+ str(trip.key.urlsafe()) +"')"})
        #get tracks from trip
        track_query = Track.query(ancestor=trip.key).order(-Track.creation_date)
        tracks = track_query.fetch(20)
        for track in tracks:
            tree.append({'id':i+10+of, 'pId':i, 'name':str(track.track_name),'click':"openTrack('"+ str(track.key.urlsafe()) +"')"})
            of += 1
        i += 1
        
    return tree
Exemple #4
0
 def get(self):
     
     user,id,url,url_linktext = self.get_user()
     
     #parameter mytrips = True if only users trips should be shown  
     mytrips = self.request.get('mytrips')
     
     if mytrips == 'True':
         trips_query = Trip.query(ancestor=helper.trip_key(id)).order(-Trip.creation_date)
     else:
         trips_query = Trip.query(Trip.visibility==True).order(-Trip.creation_date)
           
     trips, next_curs, more = trips_query.fetch_page(PAGE_SIZE)
     
     #return index page
     template_values = {'user': user, 'url': url, 'url_linktext': url_linktext,'trips':trips,'cursor':next_curs,
                        'more':more,'mytrips':mytrips}
     template = JINJA_ENVIRONMENT.get_template('templates/new/alltrips.html')
     self.response.write(template.render(template_values))
Exemple #5
0
 def trip_list(self, request):
     trips = []
     p = 10
     if request.page:
         p = request.page
     
     if request.name:
         
         trip_query = Trip.query(Trip.trip_name==request.name)
     else:
         trip_query = Trip.query()
 
     for trip in trip_query.fetch(p):
         t = TripMes(trip_name=trip.trip_name)
         if trip.trip_avatar:
             t.trip_avatar = 'http://localhost:8080/img?img_id=' + trip.key.urlsafe()
         t.description = trip.description
         t.cities = trip.cities
         if request.stat == True:
             t.trip_statistic = StatisticMes(total_time=request.name)
         trips.append(t)
     return TripCollection(items=trips)
Exemple #6
0
 def post(self):
     
     trips_query = Trip.query(Trip.visibility==True).order(-Trip.creation_date)
            
     #get cursor to fetch only new trips
     curs = Cursor(urlsafe=self.request.get('cursor'))
     trips, next_curs, more = trips_query.fetch_page(PAGE_SIZE, start_cursor=curs)
     tripsstats = {}
     #get all statistics
     for trip in trips:
         stat_query = TrackStatistic.query(ancestor=trip.key).fetch(1)
         tripsstats[trip.key]=stat_query
     data = self.create_trip_html(trips,tripsstats)
     # Create an array
     array = {'trips': data,'next_curs':next_curs.urlsafe(),'more':more}
    
     # Output the JSON
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(array))
Exemple #7
0
def get_need_passenger_trip():
    need_passenger_trips_query = Trip.query().filter(ndb.AND(Trip.is_available==True, Trip.driver!=None))
    need_passenger_trips = need_passenger_trips_query.order(Trip.driver, Trip.pick_up_time).fetch()
    return need_passenger_trips
Exemple #8
0
def get_passenger_trips_from_account_info(account_info):
    parent_key = get_parent_key(account_info.rose_username)
    passenger_trips = Trip.query().filter(Trip.passengers.IN([account_info.key])).order(Trip.passengers, Trip.pick_up_time).fetch()
    return passenger_trips
Exemple #9
0
def get_driver_trips_from_account_info(account_info):
    driver_trips = Trip.query(Trip.driver==account_info.key).order(Trip.pick_up_time).fetch()
    return driver_trips;
Exemple #10
0
def get_filtered_query_for_all_trips_for_email(email, filter_type):
    parent_key = get_parent_key_for_email(email)
    return Trip.query(ancestor=parent_key).order(filter_type)
Exemple #11
0
def get_query_for_all_distinct_states_count_for_email(email):
    parent_key = get_parent_key_for_email(email)
    return Trip.query(ancestor=parent_key, projection=["state"],
                      distinct=True).count()