def verifica_user(): user_json = session['barzinga_user'] user = User.query().filter(User.email == user_json["email"]).get() dx = user_json['email'].endswith('@dextra-sw.com') mutant = user_json['email'].endswith('@mutantbr.com') if not dx and not mutant: raise Exception('Invalid domain %s' % user_json['email']) if not user: # user = User(name = user_json['name'], email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, rfid=str('')) user = User(name = '', email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, infra=False, rfid=str(''), active = True) user.put() user_document = search.Document( fields=[ search.TextField(name='name', value=user.name), search.TextField(name='email', value=user.email) ]) search.Index(name='user').put(user_document) elif not user.photo_url: user.photo_url = user_json['picture'] user.put() identity = Identity(user.key.id()) identity_changed.send(current_app._get_current_object(), identity=identity)
def add(): name = request.form['name'] email = request.form['email'] rfid = request.form['rfid'] user = User(name=name, email=email, admin=False, photo_url='', money=0, rfid=rfid) user.put() user_document = search.Document(fields=[ search.TextField(name='name', value=user.name), search.TextField(name='email', value=user.email) ]) search.Index(name='user').put(user_document) return '', 204
def verifica_user(): user_json = session['barzinga_user'] user = User.query().filter(User.email == user_json["email"]).get() if not user: # user = User(name = user_json['name'], email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, rfid=str('')) user = User(name = '', email=user_json['email'], photo_url=user_json['picture'], money=0.0, admin=False, rfid=str('')) user.put() user_document = search.Document( fields=[ search.TextField(name='name', value=user.name), search.TextField(name='email', value=user.email) ]) search.Index(name='user').put(user_document) elif not user.photo_url: user.photo_url = user_json['picture'] user.put() identity = Identity(user.key.id()) identity_changed.send(current_app._get_current_object(), identity=identity)