Esempio n. 1
0
def FetchMPGList():
    mpglist = []
    
    
    query = mpg_db.Miles_And_Fuel.query(ancestor=mpg_db.user_key())
    for mpg in query.fetch(100):
        try:
            createdvalue = str(mpg.created)
        except:
            createdvalue = ""
        mpgItem = fillup(miles = mpg.miles, gallons=mpg.gallons, id=mpg.key.urlsafe(), created=createdvalue)
        mpglist.append(mpgItem)    
        
        
    return mpglist    
Esempio n. 2
0
    def post_mpg(self, request):

        note = mpg_db.Miles_And_Fuel(parent=mpg_db.user_key(), miles=request.miles, gallons=request.gallons)
        note.put()


        query = mpg_db.Miles_And_Fuel.query()
        mpglist = FetchMPGList()
       
        for mpg in mpglist:
            if mpg.id == note.key.urlsafe():
                break
        else:
            mpglist.append(fillup(miles = request.miles, gallons = request.gallons, id=note.key.urlsafe(), created=str(datetime.datetime.now())))
        
        mpg_db
        
        return MPGList(mpglist=mpglist, totalmpg = TotalMPG(mpglist))