def update_stream(self, image_): stream_id = self.request.get('stream_id') comment = self.request.get('comment') lat = self.request.get('Latitude') lng = self.request.get('Longitude') description = self.request.get('description') step = self.request.get('step') woInstructions = {} woPics = {} if (lat == '') or (lng == ''): lat = 0.0 lng = 0.0 photo = Photo(image=image_, stream_id=stream_id, comment=comment, Latitude=lat, Longitude=lng) key = photo.put() stream = Stream.query_by_id(int(stream_id)) if (stream.woPics == None): print "no pics in steps" woPics[step] = key.id() else: print "pics present" woPics = stream.woPics if type(woPics) is not dict: woPics = ast.literal_eval(woPics) woPics[step] = key.id() print woPics if (stream.woInstructions == None): print "no inst in steps" woInstructions[step] = description else: print "inst present" woInstructions = stream.woInstructions if type(woInstructions) is not dict: woInstructions = ast.literal_eval(woInstructions) woInstructions[step] = description if len(stream.cover) == 0: stream.cover = str(key.id()) stream.photos.append(key.id()) stream.woPics = woPics stream.woInstructions = woInstructions print "number of keys is %d" % len(woPics.keys()) stream.totalSteps = len(woPics.keys()) stream.put()
def post(self): img = self.request.get('image') stream_id = self.request.get('stream_id') comment = self.request.get('comment') photo = Photo(image=img, stream_id=stream_id, comment=comment) key = photo.put() print img, stream_id, comment stream = Stream.query_by_id(int(stream_id)) if len(stream.cover) == 0: stream.cover = str(key.id()) stream.photos.append(key.id()) stream.put()
def update_stream(self, image_): stream_id = self.request.get('stream_id') comment = self.request.get('comment') lat = self.request.get('Latitude') lng = self.request.get('Longitude') description = self.request.get('description') step = self.request.get('step') woInstructions = {} woPics = {} if (lat == '') or (lng == ''): lat = 0.0 lng = 0.0 photo = Photo(image=image_, stream_id=stream_id, comment=comment, Latitude=lat, Longitude=lng) key = photo.put() stream = Stream.query_by_id(int(stream_id)) if(stream.woPics == None): print "no pics in steps" woPics[step]=key.id() else: print "pics present" woPics= stream.woPics if type(woPics) is not dict: woPics = ast.literal_eval(woPics) woPics[step]=key.id() print woPics if(stream.woInstructions == None): print "no inst in steps" woInstructions[step] = description else: print "inst present" woInstructions=stream.woInstructions if type(woInstructions) is not dict: woInstructions=ast.literal_eval(woInstructions) woInstructions[step] = description if len(stream.cover) == 0: stream.cover = str(key.id()) stream.photos.append(key.id()) stream.woPics = woPics stream.woInstructions = woInstructions print "number of keys is %d" % len(woPics.keys()) stream.totalSteps = len(woPics.keys()) stream.put()