def post(self): print('1') original_url = self.request.headers['Referer'] img = self.get_uploads()[0] stream_name = re.findall('=(.*)', original_url)[0] if Stream.author == users.get_current_user(): stream = Stream.query( Stream.name == stream_name, Stream.author == users.get_current_user()).fetch()[0] #for img in imgs: print('3') picture = Picture(parent=db.Key.from_path('Stream', stream_name), imgkey=str(img.key())) stream.lastnewdate = picture.uploaddate pic_count = Count_pic.query( ancestor=ndb.Key('Stream', stream_name)).fetch()[0] print pic_count # print(pic_counts) # for pic_count in pic_counts: pic_count.numbers = pic_count.numbers + 1 pic_count.put() if stream.tag != None: picture.caption = stream.tag[0] #stream.numberofpictures=pic_count.numbers #stream.total=stream.total+1 #picture.id=str(stream.total) #img=img.resize((300,300)) # picture.imgkey=str(img.key()) # print picture.imgkey picture.put() stream.put() # print('!!') #print (stream.numberofpictures) # print (stream.total) #time.sleep(5.0) else: self.response.out.write('<h2 >Action not allowed!</h2>') print('5') self.redirect(original_url)
def post(self): upload = self.get_uploads()[0] stream_name = self.request.params['stream_name'] img_location_lat = float(self.request.params['locationLat']) img_location_long = float(self.request.params['locationLong']) print(img_location_long) print(img_location_lat) email = self.request.params['email'] user_photo = Picture(parent=db.Key.from_path('Stream', stream_name), imgkey=str(upload.key()), loc=db.GeoPt(img_location_lat, img_location_long)) caption = self.request.params['photoCaption'] if caption != None: user_photo.caption = caption print(user_photo.loc) user_photo.put() stream = Stream.query(Stream.name == stream_name).fetch()[0] stream.lastnewdate = user_photo.uploaddate pic_count = Count_pic.query( ancestor=ndb.Key('Stream', stream_name)).fetch()[0] # print(pic_counts) # for pic_count in pic_counts: pic_count.numbers = pic_count.numbers + 1 pic_count.put() #print (stream) #print (pic_count.numbers) #print (stream.numberofpictures) #print (stream.total) #stream.numberofpictures=pic_count.numbers #stream.total=stream.total+1 #picture.id=str(stream.total) #img=img.resize((300,300)) # picture.imgkey=str(img.key()) # print picture.imgkey # picture.put() stream.put()