Esempio n. 1
0
def geotag_post():
    if g.user_id:

        # lat = request.form['lat'] if ('lat' in request.form) and request.form['lat'] else 1
        # long = request.form['long'] if 'long' in request.form else ''
        # pic = request.form['pic'] if 'pic' in request.form else ''
        # stamp = request.form['stamp'] if ('stamp' in request.form) and request.form['stamp'] else 1
        # price = float(request.form['price']) if 'price' in request.form else 1.0
        # currency = request.form['currency'] if ('currency' in request.form) and request.form['currency'] else 'CNY'

        lat = float(request.form['lat']) if 'lat' in request.form else None
        long = float(request.form['long']) if 'long' in request.form else None
        title = request.form['title'] if 'title' in request.form else ''
        owner = User.objects(id=g.user_id).first()

        geotag = Geotag(title=title,
                        owner=owner,
                        loc=[lat,long])
        geotag.save()

        geotag_item = {
            'geotag_id':str(geotag.id),
            'loc':[geotag.lat, geotag.long],
            'create_at':pin.create_at.strftime('%Y-%m-%d %H:%M:%S'),
            }

        return (json.dumps(geotag_item), 200)
    return ('post geotag session timeout', 400)
Esempio n. 2
0
def geotags(lat, long):
    if g.user_id:
        geotags = Geotag.objects(loc__near=[lat, long])[:5]
        res_data = geotags_pack(geotags)
        return (json.dumps(res_data), 200)
    return ('geotags session timeout', 400)