def add_data(): if request.method == 'GET': #utente usr = User() usr.nome = "Luca" usr.cognome = "Puggioninu" usr.uuid = str(uuid.uuid4()) usr.password = hashlib.sha1("ciaone").hexdigest() usr.email = "*****@*****.**" usr.targa = "GF6543" usr.tariffa = "Tariffa 1" usr.is_valid = True usr.put() #admin usr = User() usr.nome = "Claudio" usr.cognome = "Marche" usr.uuid = str(uuid.uuid4()) usr.password = hashlib.sha1("ciaone").hexdigest() usr.email = "*****@*****.**" usr.tariffa = "Tariffa 1" usr.targa = "GF6543" usr.is_valid = True usr.has_superuser = True usr.put() #tariffa tar = Tariffa() tar.tariffa = 'Tariffa 1' tar.description = "La piu' bella gazz" tar.prezzo = 5.00 tar.order = 1 tar.visibilita = True tar.put() tar = Tariffa() tar.tariffa = 'Tariffa 2' tar.description = "La meno bella gazz" tar.order = 2 tar.prezzo = 5.00 tar.visibilita = False tar.put() #parcheggi state = ['Libero', 'Prenotato', 'Occupato', 'Fuori Servizio'] for piano in ['A', 'B', 'C', 'D']: for i in range(1, 41): parking = Parking() parking.piano = piano parking.number = i parking.stato = state[randint(0, 3)] parking.put() flash("Dati Aggiunti") return redirect(url_for('auth.login'))
def auth_user(name, surname): try: # ndb.delete_multi(Models.Categorie.query(Models.Categorie.categoriaID == id).fetch(keys_only=True).get()) usr = User().query(User.nome == name and User.cognome == surname).fetch(1)[0] usr.is_valid = True usr.put() return 'Utente abilitato!' except: return "Errore nell'abilitazione dell'utente!"