Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
        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)
Ejemplo n.º 3
0
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)

Ejemplo n.º 4
0
    cursor = db.cursor()
    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")
Ejemplo n.º 5
0
from app.gui.page import Page
from app.gui.gui import Gui

from .register import register_page
from .login import login

home = Page("home", title="Accueil")

home.append_item(register_page)
home.append_item(login)

#mode_select_page.set_next(main)
Ejemplo n.º 6
0
from app.entities.personne import Personne
from app.utils.path import get_config_path
import app.gui.pages.inquirer as inquirer
import logging
from .adresse import get_address
from app.entities.addrese import Addresse
import json
import mysql.connector
import functools
config = {}
with open(get_config_path("db.json"), "r") as f:
    config = json.load(f)

db = mysql.connector.connect(**config)

profil_page = Page("Profile")


def change_address():
    g = Gui()
    current_user = g.user
    query = "DELETE FROM adresse WHERE id = {}".format(current_user.adresse_id)
    logging.debug("EXECUTING QUERY: %s", query)
    cursor = db.cursor()
    cursor.execute(query)
    db.commit()
    if cursor.rowcount > 0:
        address = Addresse.create(**get_address())
        current_user.adresse_id = address.id
        current_user.save()
        print("Mise à jour de l'adresse effectué!")
Ejemplo n.º 7
0
from app.gui.page import Page
from app.gui.gui import Gui
from .main import main

mode_select_page = Page("User type select")

def set_user_mode(mode):
   g = Gui()
   g.user_type = mode
   return True

mode_select_page.append_item(lambda : set_user_mode("proprietaire"), "Propriétaire")
mode_select_page.append_item(lambda : set_user_mode("locataire"), "Locataire")
mode_select_page.set_next(main)
Ejemplo n.º 8
0
                          message="Souhaitez-vous réserver ce bien (O/N) ?",
                          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_)
Ejemplo n.º 9
0
from app.gui.page import Page
from app.gui.gui import Gui
from app.db.entity_manager import EntityManager
from app.entities.personne import Personne

from .past_rental import PastRental
from .confirmed_rental import ConfirmedRental
from .waiting_rental import WaitingRental

RentalMenu = Page("MyRentals", title="Mes locations")
RentalMenu.append_item(PastRental)
RentalMenu.append_item(ConfirmedRental)
RentalMenu.append_item(WaitingRental)
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
         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()
Ejemplo n.º 12
0
from app.gui.page import Page
from app.gui.gui import Gui
from .search import search
from .my_rentals import RentalMenu

from .my_properties import manage_properties
from .profil import profil_page
main = Page("main", title="Dashboard")

def change_menu():
   g = Gui()
   user_type = g.user_type

   if user_type == "proprietaire":
      main.append_item(search)
      main.append_item(RentalMenu)
      main.append_item(manage_properties)
      main.append_item(profil_page)
   else:
      main.append_item(search)
      main.append_item(RentalMenu)
      main.append_item(profil_page)

main.set_before_show(change_menu)

# mainMenuPage = Page("Menu principale", should_exit=True)
# mainMenuPage.append_item(search)