def getQueryRes(query): cu = db.cursor(dictionary=True) cu.execute(query) return cu.fetchall() def displayRental(): g = Gui() # a ajouter avant where query = "SELECT * FROM location_personne INNER JOIN search_biens ON bien_immobilier_id = search_biens.bien_id WHERE DATE_ADD(location_personne.date_arrivee, INTERVAL location_personne.duree DAY) < NOW() AND location_personne.estConfirme = TRUE AND personne_id = {}".format(g.user.id) locations = getQueryRes(query) headerBiens = ["Cap. person.", "Taille (m²)", "type_bien", "Description", "Rue","Commune", "Etat", "date arrivee", "date depart"] biens = [] for location in locations: biens.append([location["capacite"], location["taille"], location["type_bien"], location["description"], location["rue"], location["commune"], location["etat"],location["date_arrivee"],location["date_depart"] ]) if biens: print( tt.to_string( data=biens, header=headerBiens, style=tt.styles.ascii_thin_double, )) input("Appuyez sur une touche") return True PastRental = Page("Past Rental") PastRental.set_main(displayRental)
query = "SELECT * FROM location_personne INNER JOIN search_biens ON bien_immobilier_id = search_biens.bien_id WHERE location_personne.date_arrivee > NOW() AND location_personne.estConfirme IS NULL AND personne_id = {}".format( g.user.id) logging.debug(query) locations = getQueryRes(query) headerBiens = [ "Cap. person.", "Taille (m²)", "type_bien", "Description", "Rue", "Commune", "Etat", "date arrivee", "date depart" ] biens = [] for location in locations: biens.append([ location["capacite"], location["taille"], location["type_bien"], location["description"], location["rue"], location["commune"], location["etat"], location["date_arrivee"], location["date_depart"] ]) if biens: print( tt.to_string( data=biens, header=headerBiens, style=tt.styles.ascii_thin_double, )) input("Appuyez sur une touche") return True WaitingRental = Page("Waiting Rental") WaitingRental.set_main(displayRental)
inquirer.Password("password", "Mot de passe") ] while "Verfication de l'utilisateur": try: answers = inquirer.prompt(questions) if len(answers.keys()) != 2: return False username = answers["email"] password = answers["password"] #cuGetTypeBien = db.cursor(dictionary=True) users = Personne.where( "email= '{}' AND mot_de_passe='{}' LIMIT 0,1".format( username, password)) #userRes = cuGetTypeBien.fetchall() if len(users) == 1: g = Gui() g.user = users[0] userId = users[0].id break print("L'utilisateur n'existe pas") except KeyboardInterrupt: return False return True login = Page("Login") login.set_main(login_) login.set_next(mode_select_page)
cursor.execute(query) try: db.commit() if cursor.rowcount > 0: print("Location mis à jour avec succès") return True else: print("Impossible de mettre à jour la location") return False except: db.rollback() Page.wait_input() my_properties = Page("my_properties", title="Gérer mes biens") my_properties.set_main(my_properties_) my_properties.set_next(my_properties) pending_locations = Page("pending_rentals", title="Locations en attente") pending_locations.set_main(waiting_rentals) pending_locations.set_next(pending_locations) rentals_occuring_now = Page("rentals_occuring_now", title="Locations en cours") rentals_occuring_now.set_main(rentals_now) rentals_in_the_past = Page("past_rentals", title="Locations terminées") rentals_in_the_past.set_main(rentals_before) rentals_in_the_future = Page("future_rentals", title="Locations qui vont arriver") rentals_in_the_future.set_main(rentals_future)
validate=lambda x: x is "O" or x is "N") ]) # si O on réserve autrement on réaffiche les résultats if reserver.get('ouiNon') is "O": if startDate == "": startDate, duration = askDate(False) g = Gui() isFreeQuery = getQueryRes( "SELECT bien_est_libre({},'{}',{})".format( goodsRes[idx][0], startDate, duration)) query = "INSERT INTO location(date_arrivee, duree, estConfirme, locataire_id, bien_immobilier_id) VALUES('{}',{}, NULL,{},{})".format( startDate, duration, g.user.id, goodsRes[idx][0]) if isFreeQuery[0][0] and insert(query): print("Votre réservation à bien été faite...") input("Appuyez sur une touche") return True else: print("Bien indisponible") input("Appuyez sur une touche") return False # Search page search = Page("search", title="Rechercher un bien") search.set_main(search_)
query = "SELECT * FROM location_personne INNER JOIN search_biens ON bien_immobilier_id = search_biens.bien_id WHERE location_personne.date_arrivee > NOW() AND location_personne.estConfirme IS TRUE AND personne_id = {}".format( g.user.id) logging.debug(query) locations = getQueryRes(query) headerBiens = [ "Cap. person.", "Taille (m²)", "type_bien", "Description", "Rue", "Commune", "Etat", "date arrivee", "date depart" ] biens = [] for location in locations: biens.append([ location["capacite"], location["taille"], location["type_bien"], location["description"], location["rue"], location["commune"], location["etat"], location["date_arrivee"], location["date_depart"] ]) if biens: print( tt.to_string( data=biens, header=headerBiens, style=tt.styles.ascii_thin_double, )) input("Appuyez sur une touche") return True ConfirmedRental = Page("Confirmed Rental") ConfirmedRental.set_main(displayRental)
break logging.debug("Creating user (%s) with values %s", entity, answers) for field, value in answers.items(): setattr(entity, field, value) logging.debug("Entite personne %s", entity) print("\nMerci, maintenant nous voulons encore recuillir votre adresse \n") ad_data = get_address() if not len(ad_data.keys()): return False adresse = Addresse.create(**ad_data) p = Personne(**answers) p.adresse_id = adresse.id p.save() logging.debug("personne %s", p) g = Gui() g.user = p print("Utilisateur crée avec succès!") Page.wait_input() return True register_page = Page("Enregistrer un nouvelle utilisateur") register_page.set_main(register_) register_page.set_next(mode_select_page) if __name__ == "__main__": mode_select_page.show()