def tagimage(self, imageurl, pageid, latcoord, longcoord, hood, username):
        imageurl = util.convertimageurl(imageurl)
        query = db.GqlQuery("SELECT * FROM ImageModel where imageurl = :1",
                            imageurl)
        image = query.get()

        if image is None:
            image = ImageModel(usernameupdated=username,
                               imageurl=imageurl,
                               pageid=int(pageid),
                               latcoord=latcoord,
                               longcoord=longcoord,
                               neighborhood=hood)
        else:
            image.usernameupdated = username
            image.imageurl = imageurl
            image.pageid = int(pageid)
            image.latcoord = latcoord
            image.longcoord = longcoord
            image.neighborhood = hood

        try:
            image.put()
            user = util.getuser(username)
            if (user is not None):
                user.count = user.count + 1
            else:
                user = UserModel(username=username, count=1)

            user.put()
            return True
        except Exception, err:
            logging.error(str(err))
            return False
Exemple #2
0
    def adduser(self, username):
        user = util.getuser(username)
        if (user is not None):
            return False

        user = UserModel(username=username, count=0)
        try:
            user.put()
            return True
        except Exception, err:
            logging.error(str(err))
Exemple #3
0
    def get():
        data = request.get_json()

        # Richiede i dati di login, ovvero nome utente e password
        if not data['email'] and not data['password']:
            return {"Error": "Bad request"}, 400

        user = UserModel(data['email'])

        # confronta i dati inseriti con quelli presenti nel database
        if not check_password_hash(user.password, data['password']):
            return {"Error": "Unauthorized"}, 401

        # ritorna un token jwt con le info prescelte
        return {"token": sign_token()}, 200
    def ignoreimage(self, imageurl, username):

        imageurl = util.convertimageurl(imageurl)

        try:
            user = util.getuser(username)
            if (user is not None):
                user.count = user.count + 1
            else:
                user = UserModel(username=username, count=1)

            user.ignored_images.append(imageurl)
            user.put()
            return True
        except Exception, err:
            logging.error(str(err))
            return False
Exemple #5
0
    def post():
        data = request.get_json()

        if not data['email'] and not data['password'] and not data[
                'name'] and not data['surname']:
            return {"Error": "Bad request"}, 400

        data['password'] = generate_password_hash(data['password'])

        user = UserModel(data['email'])
        user.name = data['name']
        user.surname = data['surname']
        user.password = data['password']

        try:
            user.push()
        except KeyError:
            return {"Error": "Server error"}, 500
        except FileExistsError:
            return {"Error": "Email already in the database"}, 400

        return {"Msg": "inserito utente"}, 200