Пример #1
0
 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()
Пример #2
0
    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()
Пример #3
0
 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()
Пример #4
0
    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()
Пример #5
0
    def get(self):
        #stream_id, start_time, end_time
        stream_id = int(self.request.get('stream_id'))
        start_time = self.request.get('start_time')
        end_time = self.request.get('end_time')
        stream = Stream.query_by_id(int(stream_id))
        stream.views = stream.views + 1
        stream.put()

        images = []
        LatLngBounds = {
            'minLat': -85,
            'maxLat': 85,
            'minLng': -180,
            'maxLng': 180,
        }

        start_time = datetime.datetime.strptime(start_time, "%b %d %Y")
        end_time = datetime.datetime.strptime(end_time, "%b %d %Y") + datetime.timedelta(days=1, hours=12)
        print start_time, end_time
        for photo_id in stream.photos:
            photo = Photo.get_by_id(photo_id)
            if photo.updated_time >= start_time and photo.updated_time <= end_time:
                images.append({
                    'image': photo_id,
                    'updated_time': photo.updated_time.isoformat(),
                    'lat': randint(LatLngBounds['minLat'], LatLngBounds['maxLat']),
                    'lng': randint(LatLngBounds['minLng'], LatLngBounds['maxLat']),
                })
        self.response.write(json.dumps({
            'images': images,
            'status': 0,
        }))
Пример #6
0
 def get(self):
     photo_id = int(self.request.get('photo_id'))
     photo = Photo.query_by_id(photo_id)
     if photo:
         self.response.headers['Content-Type'] = 'image/png'
         self.response.out.write(photo.image)
     else:
         self.response.out.write('No image')
Пример #7
0
    def get(self):
        PhotoDistances = []
        streams = Stream.query()
        for stream in streams:
            for photo in stream.photos:
                p = Photo.query_by_id(photo)
                PhotoDistances.append({"lat":p.Latitude, "lng": p.Longitude, "stream_id":p.stream_id,
                                       "photo_id": photo, "stream_name": stream.name})

        self.response.write(json.dumps({"Distances": PhotoDistances}))