From bf06106e04ad0658cb2ba3de5dd4961d1aacc053 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Wed, 14 Jan 2015 00:39:12 +0100 Subject: [PATCH] reformat --- src/Launchme.py | 31 +--- src/__init__.py | 1 - src/c/Borne.py | 47 ++++-- src/c/CreaParking.py | 16 +- src/c/Main.py | 26 ++-- src/c/SelectService.py | 55 +++++++ src/c/Teleporteur.py | 16 +- src/m/Abonnement.py | 13 -- src/m/Client.py | 91 +++++------ src/m/ConnecxionBDD.py | 26 ---- src/m/Contrat.py | 23 --- src/m/Entretien.py | 19 --- src/m/ListeTypePlace.py | 26 ---- src/m/Livraison.py | 29 ---- src/m/Maintenance.py | 18 --- src/m/Parking.py | 312 +++++++++++++++++++++++++++++++++----- src/m/Place.py | 79 ---------- src/m/Placement.py | 53 ------- src/m/Service.py | 49 +----- src/m/TypeAbonnement.py | 6 - src/m/TypePlace.py | 24 --- src/m/Voiture.py | 63 ++++++-- src/m/Voiturier.py | 28 ---- src/m/connexionBDD.py | 32 +++- src/m/table.sql | 78 ++++++++-- src/m/test/TestParking.py | 16 -- src/m/test/TestPlace.py | 5 - src/m/test/__init__.py | 1 - src/m/test/test.py | 0 src/m/test/testClient.py | 14 -- src/m/test/testPlacement | 5 - src/m/test/testService.py | 7 - src/v/Camera.py | 2 +- src/v/MyQWidget.py | 3 +- src/v/Ui_Service.py | 78 ++++++++++ 35 files changed, 647 insertions(+), 645 deletions(-) delete mode 100644 src/__init__.py create mode 100644 src/c/SelectService.py delete mode 100644 src/m/Abonnement.py delete mode 100644 src/m/ConnecxionBDD.py delete mode 100644 src/m/Contrat.py delete mode 100644 src/m/Entretien.py delete mode 100644 src/m/ListeTypePlace.py delete mode 100644 src/m/Livraison.py delete mode 100644 src/m/Maintenance.py delete mode 100644 src/m/Place.py delete mode 100644 src/m/Placement.py delete mode 100644 src/m/TypeAbonnement.py delete mode 100644 src/m/TypePlace.py delete mode 100644 src/m/Voiturier.py delete mode 100644 src/m/test/TestParking.py delete mode 100644 src/m/test/TestPlace.py delete mode 100644 src/m/test/__init__.py delete mode 100644 src/m/test/test.py delete mode 100644 src/m/test/testClient.py delete mode 100644 src/m/test/testPlacement delete mode 100644 src/m/test/testService.py create mode 100644 src/v/Ui_Service.py diff --git a/src/Launchme.py b/src/Launchme.py index 49fe44b..e6b9709 100644 --- a/src/Launchme.py +++ b/src/Launchme.py @@ -1,39 +1,16 @@ import sqlite3 from src.c.Main import Main +from src.m.connexionBDD import connexionBDD __author__ = 'sidya' -class connexionBDD: - def __init__(self): - try: - self.__conn = sqlite3.connect("BD.sql3") - self.__cur = self.__conn.cursor() - except Exception as e: - pass # later - - def seDeconnecter(self): - self.__cur.close() - self.__conn.close() - - def execute(self, req): - try: - r = self.__cur.execute(req) - self.__conn.commit() - except Exception as e: - pass # later - return r - - - def lastId(self): - return self.__cur.lastrowid - - -conn = connexionBDD - if __name__ == "__main__": + c = connexionBDD() + c.initialisationBDD() + c.seDeconnecter() # lancement du controleur principal main = Main() diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index 934a683..0000000 --- a/src/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__author__ = 'sidya' diff --git a/src/c/Borne.py b/src/c/Borne.py index 5bbd4be..805adee 100644 --- a/src/c/Borne.py +++ b/src/c/Borne.py @@ -1,9 +1,11 @@ from PyQt4 import QtGui +from src.c.SelectService import SelectService from src.c.Teleporteur import Teleporteur -from src.m.Placement import Placement +from src.m.Parking import Placement from src.m.Client import Client -from src.m.TypeAbonnement import TypeAbonnement +from src.m.Service import Service +from src.m.Client import TypeAbonnement from src.v.Camera import Camera from src.v.MyQWidget import MyQWidget from src.v.Ui_Borne import Ui_Borne @@ -39,7 +41,8 @@ class Borne: # Validator - self.__ui.nomParking = parking.nom + self.__ui.label_aff.setText("Dream park") + self.__ui.nomParking.setText(parking.nom) self.nonVoiture() self.showWindow() @@ -94,13 +97,15 @@ class Borne: TypeAbonnement.SUPER_ABONNE) self.__ui.label_aff.setText("Mise a jour de votre abonnement effectué") else: - if self.__ui.checkBox.isEnabled(): - self.__c = Client(self.__ui.nomLineEdit, + if self.__ui.checkBox.isChecked(): + self.__c = Client(None, + self.__ui.nomLineEdit, self.__ui.prenomLineEdit, "", TypeAbonnement.SUPER_ABONNE) else: - self.__c = Client(self.__ui.nomLineEdit, + self.__c = Client(None, + self.__ui.nomLineEdit, self.__ui.prenomLineEdit, "", TypeAbonnement.ABONNE) @@ -114,13 +119,26 @@ class Borne: :return: """ if self.__c is None: - id = Teleporteur.teleporterVoiture(self.v_actuel, self.__parking.recherchePlace(self.v_actuel)) - self.__ui.label_aff.setText("Votre num ticket est : " + id) + p = self.__parking.recherchePlace(self.v_actuel) + if p is None : + self.__ui.label_aff.setText("Aucun Place disponible") + else : + id = Teleporteur.teleporterVoiture(self.v_actuel, p) + self.__ui.label_aff.setText("Votre num ticket est : " + str(id)) + self.nonVoiture() else: if self.__c.abonnement != TypeAbonnement.SUPER_ABONNE: - Teleporteur.teleporterVoiture(self.v_actuel, self.__parking.recherchePlace(self.v_actuel)) + p = self.__parking.recherchePlace(self.v_actuel) + if p is None : + self.__ui.label_aff.setText("Aucun Place disponible") + else : + id = Teleporteur.teleporterVoiture(self.v_actuel, self.__parking.recherchePlace(self.v_actuel)) + self.__w.hide() + self.__child = SelectService(self.__main) + self.__ui.label_aff.setText("Votre num ticket est : " + str(id)) + self.nonVoiture() else: - Teleporteur.teleporterVoirureSuperAbonne(self.v_actuel) + Teleporteur.teleporterVoitureSuperAbonne(self.v_actuel) def recuperer(self): @@ -128,12 +146,13 @@ class Borne: Essaie de recuperer une voiture avec le numero de ticket (lineedit) :return: """ - p = Placement.get(self.__ui.numeroTicketLineEdit.text()) - if p is None: - self.__ui.label_aff.setText("Mauvais numero de ticket") - else: + try : + p = Placement.get(self.__ui.numeroTicketLineEdit.text()) Teleporteur.teleporterVersSortie(p) self.__ui.label_aff.setText("Bonne journée") + except IndexError: + self.__ui.label_aff.setText("Mauvais numero de ticket") + def showWindow(self): diff --git a/src/c/CreaParking.py b/src/c/CreaParking.py index 15260dd..091a33a 100644 --- a/src/c/CreaParking.py +++ b/src/c/CreaParking.py @@ -1,7 +1,6 @@ from PyQt4 import QtGui -from src.m.Parking import Parking -from src.m.ListeTypePlace import ListeTypePlace +from src.m.Parking import Parking, TypePlace from src.v.MyQWidget import MyQWidget from src.v.Ui_CreaParking import Ui_CreaParking @@ -13,7 +12,6 @@ class CreaParking: """ Controleur de cretion de parking """ - def __init__(self, main): self._main = main self._main.activity("Debut Creation Parking", self._main.lvl.INFO) @@ -76,14 +74,12 @@ class CreaParking: :return: """ # try: - l = ListeTypePlace() + l = [] for i in range(0, self._ui.tableWidget.rowCount()): - l.add(int(self._ui.tableWidget.item(i, 0).text()), int(self._ui.tableWidget.item(i, 1).text()), - int(self._ui.tableWidget.item(i, 2).text())) - self._main.addParking(Parking( - l, - self._ui.lineEdit_nom.text())) - self._main.activity("Ajout Parking : detail", self._main.lvl.INFO) + l.append(TypePlace(None,int(self._ui.tableWidget.item(i, 0).text()), int(self._ui.tableWidget.item(i, 1).text()), + int(self._ui.tableWidget.item(i, 2).text()))) + p = Parking(self._ui.lineEdit_nom.text(),l) + self._main.activity("Ajout:" + str(p), self._main.lvl.INFO) self._w.hide() self._main.showWindow() #except Exception as e: diff --git a/src/c/Main.py b/src/c/Main.py index 9f74a7a..f71821c 100644 --- a/src/c/Main.py +++ b/src/c/Main.py @@ -7,6 +7,7 @@ from src.c.DetailsPlaces import DetailsPlaces from src.c.log.log import Log from src.c.log.log import lvl from src.c.CreaParking import CreaParking +from src.m.Parking import Parking from src.v.MyQMainWindow import MyQMainWindow from src.v.Ui_MainWindow import Ui_MainWindow @@ -19,9 +20,6 @@ class Main: self.lvl = lvl() # Public : Acces au constante self.__log = Log() - # Parking - self.__parkings = [] - app = QtGui.QApplication(sys.argv) self.__view = MyQMainWindow() @@ -68,7 +66,7 @@ class Main: def majListeParking(self): self.__ui.comboBox.clear() self.__ui.comboBox.addItem("Selectionner un parking") - for p in self.__parkings: + for p in Parking.getAll(): self.__ui.comboBox.addItem(p.nom) def selectParking(self): @@ -77,25 +75,19 @@ class Main: self.__ui.placesDispo.clear() self.__ui.placesSuperAbo.clear() if self.__ui.comboBox.count() > 1: - print(self.__ui.comboBox.count()) - self.__ui.nom.setText(self.__parkings[self.__ui.comboBox.currentIndex() - 1].nom) - self.__ui.placesParNiveau.setText(str(self.__parkings[self.__ui.comboBox.currentIndex() - 1].nbPlaces)) + p = Parking.getAll() + self.__ui.nom.setText(p[self.__ui.comboBox.currentIndex() - 1].nom) + self.__ui.placesParNiveau.setText(str(p[self.__ui.comboBox.currentIndex() - 1].nbPlaces)) self.__ui.placesDispo.setText( - str(self.__parkings[self.__ui.comboBox.currentIndex() - 1].nbPlacesLibresParking)) - self.__ui.placesSuperAbo.setText("lol") + str(p[self.__ui.comboBox.currentIndex() - 1].nbPlacesLibresParking)) + self.__ui.placesSuperAbo.setText(str(p[self.__ui.comboBox.currentIndex() - 1].nbSuperAbo)) def creerParking(self): self.__view.hide() self.__widgetCourant = CreaParking(self) - def addParking(self, parking): - self.__parkings.append(parking) - def modifParking(self): - if self.__ui.comboBox.currentIndex() != 0: - self.__view.hide() - self.__widgetCourant = ModifParking(self, self.__parkings[self.__ui.comboBox.currentIndex() - 1]) def rmParking(self): if self.__ui.comboBox.currentIndex() != 0: @@ -113,12 +105,12 @@ class Main: def detailsPlacesParking(self): if self.__ui.comboBox.currentIndex() != 0: self.__view.hide() - self.__widgetCourant = DetailsPlaces(self, self.__parkings[self.__ui.comboBox.currentIndex() - 1]) + self.__widgetCourant = DetailsPlaces(self, Parking.getAll()[self.__ui.comboBox.currentIndex() - 1]) def afficherBorne(self): if self.__ui.comboBox.currentIndex() != 0: self.__view.hide() - self.__widgetCourant = Borne(self, self.__parkings[self.__ui.comboBox.currentIndex() - 1]) + self.__widgetCourant = Borne(self, Parking.getAll()[self.__ui.comboBox.currentIndex() - 1]) def showWindow(self): diff --git a/src/c/SelectService.py b/src/c/SelectService.py new file mode 100644 index 0000000..ca1b444 --- /dev/null +++ b/src/c/SelectService.py @@ -0,0 +1,55 @@ +from PyQt4 import QtGui +from src.v.MyQWidget import MyQWidget +from src.v.Ui_Service import Ui_Service + + +__author__ = 'sidya' + + +class SelectService: + """ + Controleur de cretion de parking + """ + def __init__(self, main): + self.__main = main + self.__main.activity("Choix Service", self.__main.lvl.INFO) + + self._w = MyQWidget(self.__main) + self.__ui = Ui_Service() + self.__ui.setupUi(self._w) + + # connect + self.__ui.btn_valider.clicked.connect(self.valider) + + # Validator + + + self.showWindow() + + + def valider(self): + """ + Gestion validation de formulaire de choix de service + :return: + """ + + + def showWindow(self): + """ + Gestion affichage vue Creation de Parking + :return: + """ + self._w.show() + self.__child = None # supprime l'eventuel widget enfant + self._w.focusWidget() # reprend le focus sur la fenetre + + def error(self): + """ + Qdialog message erreur + :return: + """ + QtGui.QMessageBox.warning(self._w, + "Erreur ...", + "Erreur lors du choix de service ...") + self._w.hide() + self.__main.showWindow() \ No newline at end of file diff --git a/src/c/Teleporteur.py b/src/c/Teleporteur.py index 9405509..f42d3d4 100644 --- a/src/c/Teleporteur.py +++ b/src/c/Teleporteur.py @@ -1,18 +1,18 @@ -from src.m.Placement import Placement +from src.m.Parking import Placement __author__ = 'sidya' class Teleporteur: - @classmethod - def teleporterVoiture(self, voiture, place): - p = Placement(voiture, place) + @staticmethod + def teleporterVoiture(voiture, place): + p = Placement(None,voiture, place,None,None) return p.id - @classmethod - def teleporterVoitureSuperAbonne(self, voiture): + @staticmethod + def teleporterVoitureSuperAbonne(voiture): pass - @classmethod - def teleporterVersSortie(self, placement): + @staticmethod + def teleporterVersSortie(placement): placement.end() \ No newline at end of file diff --git a/src/m/Abonnement.py b/src/m/Abonnement.py deleted file mode 100644 index 683eb2a..0000000 --- a/src/m/Abonnement.py +++ /dev/null @@ -1,13 +0,0 @@ -from src.m.connexionBDD import connexionBDD - - -class Abonnement: - def __init__(self, libelle, prix, estPackGar): - self.libelle = libelle - self.prix = prix - self.estPackGar = estPackGar - - def addContrat(self, contrat): - connexion = connexionBDD() - # indId= connexion.cur.execute("SELECT abonnement.idAbonnement FROM abonnement WHERE libelle = ? AND prix = ? AND estPackGar=?;"(self.libelle, self.prix, self.estPackGar)) - # idAbonnement = int(''.join(map(str,indId))) diff --git a/src/m/Client.py b/src/m/Client.py index 1f86aa6..6b2f280 100644 --- a/src/m/Client.py +++ b/src/m/Client.py @@ -1,26 +1,45 @@ import random -import sqlite3 import string +from src.m.connexionBDD import connexionBDD + __author__ = 'sidya' +class Client: + @staticmethod + def get(id): + c = connexionBDD() + r = c.execute("SELECT * FROM client WHERE idClient='"+str(id)+"'") + row = r.fetchone() + if row is None : + raise IndexError("Invalid id") + c.seDeconnecter() + return Client(id, row["nom"],row["prenom"],row["adresse"], bool(row["typeAbonnement"])) -class Client(): - clients = [] - def __init__(self, nom, prenom, adresse, typeAbonnement): - while True: - id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in - range(random.randint(1, 10))) - if Client.get(id) is None: - break - self.__id = id + def __init__(self,id, nom, prenom, adresse, typeAbonnement): self.__nom = nom self.__prenom = prenom self.__typeAbonnement = typeAbonnement self.__adresse = adresse - self.clients.append(self) + if id is None: + while True: + id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in + range(random.randint(1, 10))) + try : + Client.get(id) + except IndexError : + break + + self.__id = id + c = connexionBDD() + c.execute("INSERT INTO client (idClient, nom, prenom, adresse, typeAbonnement) VALUES (?,?,?,?,?)", + (str(self.__id), str(self.__nom), str(self.__prenom), "", str(self.__typeAbonnement))) + self.__id = id + c.seDeconnecter() + else: + self.__id = id @property def prenom(self): @@ -42,46 +61,14 @@ class Client(): def abonnement(self): return self.__typeAbonnement - @staticmethod - def get(id): - for client in Client.clients: - if client.id == id: - return client - return None - - @staticmethod - def loadAll(connection): - with connection: - connection.row_factory = sqlite3.Row - cur = connection.cursor() - cur.execute("SELECT * FROM Client") - rows = cur.fetchall() - for row in rows: - Client(row["num"], row["nom"], row["prenom"], row["adr"], int(row["abo"])) - connection.close() - - @staticmethod - def saveAll(connection): - cur = connection.cursor() - # reset table Client - cur.execute("DROP TABLE IF EXISTS Client") - cur.execute( - """create table Client (num varchar(10) PRIMARY KEY, nom varchar(30), prenom varchar(30), adr varchar(50), abo int(1))""") - # insert clients - for c in Client.tous: - cur.execute("insert into Client values (?, ?, ?, ?, ?)", (c.id, c.nom, c.prenom, c.adr, c.abonnement)) - connection.commit() - connection.close() - - def maj(self, nom, prenom, adresse, typeAbonnement): - self.__nom = nom - self.__prenom = prenom - self.__typeAbonnement = typeAbonnement - self.__adresse = adresse - def __str__(self): - return "( " + self.__id + ", " + self.__nom + ", " + self.__prenom + ", " + self.__adresse + ", " + str( - self.__typeAbonnement) + " )" - - + return "[Client :" \ + " id = " + str(self.__id) + ", " \ + " prenom = " + str(self.__prenom) + ", " \ + " nom = " + str(self.__nom) + ", " \ + " adresse = " + str(self.__adresse) + ", " \ + " typeAbonnement = " + str(self.__typeAbonnement) + "]" +class TypeAbonnement: + ABONNE = 0 + SUPER_ABONNE = 1 \ No newline at end of file diff --git a/src/m/ConnecxionBDD.py b/src/m/ConnecxionBDD.py deleted file mode 100644 index e9411de..0000000 --- a/src/m/ConnecxionBDD.py +++ /dev/null @@ -1,26 +0,0 @@ -__author__ = 'sidya' - - -class connexionBDD: - def __init__(self): - try: - self.__conn = sqlite3.connect("BD.sql3") - self.__cur = self.__conn.cursor() - except Exception as e: - pass # later - - def seDeconnecter(self): - self.__cur.close() - self.__conn.close() - - def execute(self, req): - try: - r = self.__cur.execute(req) - self.__conn.commit() - except Exception as e: - pass # later - return r - - - def lastId(self): - return self.__cur.lastrowid \ No newline at end of file diff --git a/src/m/Contrat.py b/src/m/Contrat.py deleted file mode 100644 index d8c720e..0000000 --- a/src/m/Contrat.py +++ /dev/null @@ -1,23 +0,0 @@ -from src.m.connexionBDD import connexionBDD - - -class Contrat: - def __init__(self, dateDebut, dateFin): - self.dateDebut = dateDebut - self.dateFin = dateFin - - def enregistrerContrat(self): - connection = connexionBDD() - connection.cur.execute("INSERT INTO contrat (idContrat,dateDebut,dateFin, estEncours) VALUES (NULL,?,?,1);", - ( self.dateDebut, self.dateFin, 1)) - connection.seDeconnecter() - - def rompreContrat(self, idCLient): - connection = connexionBDD() - indContrat = connection.cur.execute( - "SELECT Contrat.idContrat FROM contrat where idClient =? AND dateDebut = ? AND dateFin=? ;"(idCLient, - self.dateDebut, - self.dateFin)) - idContrat = int(''.join(map(str, indContrat))) - connection.cur.execute("Update contrat where idContrat=? set estEnCours =0;", ( idContrat)) - connection.seDeconnecter() diff --git a/src/m/Entretien.py b/src/m/Entretien.py deleted file mode 100644 index 9f513cc..0000000 --- a/src/m/Entretien.py +++ /dev/null @@ -1,19 +0,0 @@ -from src.m.Service import Service -from src.m.connexionBDD import connexionBDD - - -class Entretien(Service): - def __init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, anneeDemande, rapport, - categorie, idClient): - super(Service, self).__init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, - anneeDemande, rapport, categorie) - self.categorie = 2 - self.etat = 0 - self.idService = self.enregistrerService(self, idClient, self.categorie, self.etat) - - -def effectuerEntretien(self): - self.etat = 1 - connexion = connexionBDD() - connexion.cur.execute("UPDATE service SET etat= 1 WHERE idService = ?", (self.idService)) - connexion.seDeconnecter() \ No newline at end of file diff --git a/src/m/ListeTypePlace.py b/src/m/ListeTypePlace.py deleted file mode 100644 index 87275fb..0000000 --- a/src/m/ListeTypePlace.py +++ /dev/null @@ -1,26 +0,0 @@ -from src.m.TypePlace import TypePlace - -__author__ = 'sidya' - - -class ListeTypePlace: - """ - Classe qui permet de définir une liste de type de place par niveau pour la création d'un parking - """ - - def __init__(self): - self.l = [] - - def add(self, h, l, nb): - self.l.append(TypePlace(h, l, nb)) - - @property - def nbPlaceTotal(self): - i = 0 - for t in self.l: - i += t.nb - return i - - @property - def liste(self): - return self.l diff --git a/src/m/Livraison.py b/src/m/Livraison.py deleted file mode 100644 index f92ee1c..0000000 --- a/src/m/Livraison.py +++ /dev/null @@ -1,29 +0,0 @@ -import calendar - -from src.m.Service import Service -from src.m.connexionBDD import connexionBDD - - -class Livraison(Service): - def __init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, anneeDemande, rapport, - categorie, idClient): - super(Service, self).__init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, - anneeDemande, rapport, categorie) - self.categorie = 3 - self.etat = 0 - # 3.Obtenir l'idVoiturier: en recherchant celui qui est disponible le jour en question - self.idService = self.enregistrerService(self, idClient, self.categorie, self.etat) - jour = calendar.weekday(self.dateService._day, self.dateService._month, self.dateService._year) - connexion = connexionBDD() - indiceVoiturier = connexion.cur.execute( - "SELECT voiturier.idVoiturier FROM voiturier WHERE voiturier.joursDisponible = ?; ", (jour)) - idVoiturier = int(''.join(map(str, indiceVoiturier))) - connexion.cur.execute("UPDATE service SET idVoiturier= ? WHERE idService = ?", (idVoiturier, self.idService)) - connexion.seDeconnecter() - - def effectuerLivraison(self): - self.etat = 1 - connexion = connexionBDD() - connexion.cur.execute("UPDATE service SET etat= 1 WHERE idService = ?", (self.idService)) - connexion.seDeconnecter() - diff --git a/src/m/Maintenance.py b/src/m/Maintenance.py deleted file mode 100644 index dba1262..0000000 --- a/src/m/Maintenance.py +++ /dev/null @@ -1,18 +0,0 @@ -from src.m.Service import Service -from src.m.connexionBDD import connexionBDD - - -class Maintenance(Service): - def __init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, anneeDemande, rapport, - categorie, idClient): - super(Service, self).__init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, - anneeDemande, rapport, categorie) - self.categorie = 1 - self.etat = 0 - self.idService = self.enregistrerService(self, idClient, self.categorie, self.etat) - - def effectuerMaintenance(self): - self.etat = 1 - connexion = connexionBDD() - connexion.cur.execute("UPDATE service SET etat= 1 WHERE idService = ?", (self.idService)) - diff --git a/src/m/Parking.py b/src/m/Parking.py index 0101c44..73e8463 100644 --- a/src/m/Parking.py +++ b/src/m/Parking.py @@ -1,30 +1,44 @@ -from src.m.Place import Place +import random +import string +import datetime +from src.m.Voiture import Voiture +from src.m.connexionBDD import connexionBDD __author__ = 'sidya' + class Parking: - """ - Definie un parking - """ + parkings = [] - def __init__(self, typePlaces, nom): - """ - Creer objet parking - :param typePlaces: ListeTypePlace - :param nom: str - :return: - """ - self.__typePlaces = typePlaces + @staticmethod + def get(id): + for p in Parking.parkings : + if p.id == id : + return p + + @staticmethod + def getAll(): + return Parking.parkings + + + def __init__(self, nom, listeTypePlace): self.__nom = nom - self.__prix = 10 - self.__Places = {} - l = [] - for t in typePlaces.liste: - for i in range(0, t.nb): - l.append(Place(i + 1, 1, t.longueur, t.hauteur)) - self.__Places = l + c = connexionBDD() + c.execute("INSERT INTO parking (nom) VALUES ('"+str(self.__nom)+"')", ()) + self.__id = c.lastId() + #Crea des places + n = 0 + for typePlace in listeTypePlace : + for i in range(typePlace.nombre) : + print(Place(None,self,typePlace,1,n,True,False)) + n += 1 + self.parkings.append(self) + + @property + def id(self): + return self.__id @property def nom(self): @@ -32,16 +46,15 @@ class Parking: @property def nbPlaces(self): - return self.__typePlaces.nbPlaceTotal - + return Place.nbPlaceParking(self.__id) @property def nbPlacesLibresParking(self): - i = 0 - for p in self.__Places: - if p.estLibre: - i += 1 - return i + return Place.nbPlaceLibreParking(self.__id) + + @property + def nbSuperAbo(self): + return Place.nbSuperAbo(self.__id) def recherchePlace(self, voiture): """ @@ -49,17 +62,240 @@ class Parking: :param voiture: Voiture :return: Place """ - place = None - for p in self.__Places: - if p.estLibre and p.dimValide(voiture.getHauteur, voiture.getLongueur): - pass - place = p - break - return place - - - def addAbonnement(self, Abonnement): - pass + return Place.placeValide(self.__id, voiture) def __str__(self): - return "Parking : niveau : " + str(self.__nbNiveaux) + return "[Parking : nom = " + self.__nom +"]" + + +class Place: + @staticmethod + def get(id): + c = connexionBDD() + r = c.execute("SELECT * FROM place WHERE idPlace='"+str(id)+"'") + row = r.fetchone() + if row is None : + raise IndexError("Invalid id") + c.seDeconnecter() + return Place(id,row["idParking"],row["idTypePlace"],row["niveau"], + row["numero"],row["estLibre"],row["estSuperAbo"]) + + def __init__(self, id, parking, typePlace, niveau, numero, estLibre, estSuperAbo): + self.__parking = parking + self.__typePlace = typePlace + self.__niveau = niveau + self.__numero = numero + self.__estLibre = estLibre + self.__estSuperAbo = estSuperAbo + if id is None : + c = connexionBDD() + c.execute("INSERT INTO place (idParking, idTypePlace, niveau, numero, estLibre, estSuperAbo) " + "VALUES (?,?,?,?,?,?)", + (self.__parking.id, self.__typePlace.id,self.__niveau, + self.__numero, self.__estLibre, int(self.__estSuperAbo))) + self.__id = c.lastId() + c.seDeconnecter() + else : + self.__id = id + + def prendre(self): + """ + Rend la place indisponible + :param Placement: + :return: + """ + if (self.__estLibre == False): + raise Exception("Place déjà prise") + self.__estLibre = False + c = connexionBDD() + c.execute("UPDATE place SET estLibre = 0 WHERE idPlace = ?", (str(self.__id))) + c.seDeconnecter() + + def liberer(self): + """ + Libere une place non dispo + :return: + """ + if (self.__estLibre == True): + raise Exception("Impossible de liberer une place vide") + self.__estLibre = False + c = connexionBDD() + c.execute("UPDATE place SET estLibre = 1 WHERE idPlace = ?", (str(self.__id))) + c.seDeconnecter() + + @staticmethod + def nbPlaceParking(idParking): + c = connexionBDD() + print("lol") + r = c.execute("SELECT COUNT(*) FROM place WHERE idParking = ?", (str(idParking))) + row = r.fetchone() + c.seDeconnecter() + return row[0] + + @staticmethod + def nbPlaceLibreParking(idParking): + c = connexionBDD() + r = c.execute("SELECT COUNT(*) FROM place WHERE idParking = ? AND estLibre = 1", (str(idParking))) + row = r.fetchone() + c.seDeconnecter() + return row[0] + + @staticmethod + def nbSuperAbo(idParking): + c = connexionBDD() + r = c.execute("SELECT COUNT(*) FROM place WHERE idParking = ? AND estSuperAbo = 1", (str(idParking))) + row = r.fetchone() + c.seDeconnecter() + return row[0] + + @staticmethod + def placeValide(idPArking, voiture): + c = connexionBDD() + r = c.execute("SELECT * FROM place WHERE idParking= ? AND estLibre = 1 " + "AND idTypePlace =(SELECT idTypePlace FROM typePlace " + "WHERE hauteur>? AND longueur>? ORDER BY longueur) ", + (str(idPArking),str(voiture.hauteur),str(voiture.longueur))) + row = r.fetchone() + c.seDeconnecter() + if row is None : + return None + else : + return Place(row["idPlace"],row["idParking"], row["idtypePlace"], + row["niveau"], row["numero"], bool(row["estLibre"]), bool(row["estSuperAbo"])) + + + def __str__(self): + return "[Place : " \ + "Parking = " + str(self.__parking) + "," \ + "typePlace = " + str(self.__typePlace) + "," \ + "niveau = " + str(self.__niveau) + "," \ + "numero = " + str(self.__numero) + "," \ + "estLibre = " + str(self.__estLibre) + "," \ + "estSuperAbo = " + str(self.__estSuperAbo) + "]" \ + + @property + def id(self): + return self.__id + + + +class TypePlace: + @staticmethod + def get(id): + c = connexionBDD() + r = c.execute("SELECT * FROM typePlace WHERE idTypePlace='"+str(id)+"'") + row = r.fetchone() + if row is None : + raise IndexError("Invalid id") + c.seDeconnecter() + return TypePlace(id,row["longueur"],row["hauteur"],row["nombre"]) + + + def __init__(self, id ,longueur, hauteur, nombre): + self.__longueur = longueur + self.__hauteur = hauteur + self.__nombre = nombre + if id is None : + c = connexionBDD() + c.execute("INSERT INTO typePlace (longueur,hauteur,nombre) VALUES (?,?,?)", + (self.__longueur, self.__hauteur, self.__nombre)) + self.__id = c.lastId() + c.seDeconnecter() + else: + self.__id = id + + @property + def id(self): + return self.__id + + @property + def longueur(self): + return self.__longueur + + @property + def hauteur(self): + return self.__hauteur + + @property + def nombre(self): + return self.__nombre + + def __str__(self): + return "[TypePlace : " \ + "id = " + str(self.__id) + "," \ + "longueur = " + str(self.__longueur) + "," \ + "hauteur = " + str(self.hauteur) + "," \ + "nombre = " + str(self.nombre) + "]" + + +class Placement: + placementsEnCours = [] + + @staticmethod + def get(id): + c = connexionBDD() + r = c.execute("SELECT * FROM placement WHERE idPlacement='"+str(id)+"'") + row = r.fetchone() + if row is None : + raise IndexError("Invalid id") + c.seDeconnecter() + print(row["idVoiture"]) + return Placement(row["idPlacement"], Voiture.get(row["idVoiture"]), Place.get(row["idPlace"]), + row["debut"], row["fin"]) + + + def __init__(self,id, voiture, place, debut, fin): + """ + Creer un placement + :param voiture: Voiture + :param place: Place + :return: + """ + self.__voiture = voiture + self.__place = place + place.prendre() + self.placementsEnCours.append(self) + if id is None : + self.__debut = datetime.datetime + self.__fin = None + while True: + id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in + range(random.randint(1, 10))) + try: + Placement.get(id) + except IndexError: + break + c = connexionBDD() + c.execute("INSERT INTO placement (idPlacement,idVoiture,idPlace, debut, fin) VALUES (?,?,?,?,?)", + (str(id), str(self.__voiture.id), str(self.__place.id), str(self.__debut), "NULL")) + self.__id = id + c.seDeconnecter() + else: + self.__id = id + self.__debut = debut + self.__fin = fin + + @property + def id(self): + return self.__id + + def __str__(self): + return "[Placement : " \ + "id = " + self.__id +"," \ + "Voiture = " + self.__voiture +"," \ + "Place = " + self.__place +"," \ + "Debut = " + self.__debut +"," \ + "Fin = " + self.__fin +"]" + + + + +if __name__ == "__main__" : + c = connexionBDD() + c.initialisationBDD() + c.seDeconnecter() + listeTypePlaces = [] + listeTypePlaces.append(TypePlace(None,200, 300,10)) + listeTypePlaces.append(TypePlace(None,120, 250,15)) + p = Parking("test",listeTypePlaces) + print (p) \ No newline at end of file diff --git a/src/m/Place.py b/src/m/Place.py deleted file mode 100644 index eb7bb8c..0000000 --- a/src/m/Place.py +++ /dev/null @@ -1,79 +0,0 @@ -__author__ = 'sidya' - - -class Place: - """ - Representation d'une place - """ - - def __init__(self, numero, niveau, longueur, hauteur): - """ - Creer une place. - Les dimensions doivent etre données en cm (longueur, hauteur) - :param numero: int - :param niveau: int - :param longueur: int - :param hauteur: int - :return: - """ - self.__numero = numero - self.__niveau = niveau - self.__longueur = longueur - self.__hauteur = hauteur - self.__estLibre = True - self.__estSuperAbo = False - self.__Placement = None - - @property - def estLibre(self): - return self.__estLibre - - @property - def estReserver(self): - return self.__estSuperAbo - - def dimValide(self, h, l): - """ - Retourn si un element de hauteur (cm) h et de longueur(cm) l passe dans la place - :param h: int - :param l: int - :return: bool - """ - return h < self.__hauteur and l < self.__longueur - - def superAbo(self): - """ - Renvoit si la place est une place superAbo - :return: bool - """ - if (self.__estSuperAbo == True): - raise Exception("Place déjà reservé") - self.__estSuperAbo = True - - - def prendre(self): - """ - Rend la place indisponible - :param Placement: - :return: - """ - if (self.__estLibre == False): - raise Exception("Place déjà prise") - self.__estLibre = False - - def liberer(self): - """ - Libere une place non dispo - :return: - """ - if (self.__estLibre == True): - raise Exception("Impossible de liberer une place vide") - self.__estLibre = True - - - - - - - - diff --git a/src/m/Placement.py b/src/m/Placement.py deleted file mode 100644 index 3c26b69..0000000 --- a/src/m/Placement.py +++ /dev/null @@ -1,53 +0,0 @@ -import datetime -import random -import string - -__author__ = 'sidya' - - -class Placement: - placements = [] - - def __init__(self, voiture, place): - """ - Creer un placement - :param voiture: Voiture - :param place: Place - :return: - """ - while True: - id = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in - range(random.randint(1, 10))) - if Placement.get(id) is None: - break - self.__id = id - self.__voiture = voiture - self.__place = place - self.__debut = datetime.datetime - self.__fin = None - place.prendre() - self.placements.append(self) - - def end(self): - self.__fin = datetime.datetime - self.__place.liberer() - - @property - def id(self): - return self.__id - - @staticmethod - def get(id): - """ - Recupere le Placement d'id id - :param id: str - :return: Placement or None - """ - for p in Placement.placements: - if p.__id == id: - return p - return None - - @property - def estEnCours(self): - return datetime.datetime < self.__fin diff --git a/src/m/Service.py b/src/m/Service.py index f641cd6..27d053a 100644 --- a/src/m/Service.py +++ b/src/m/Service.py @@ -1,49 +1,4 @@ -import calendar -import datetime - -from src.m.connexionBDD import connexionBDD - +__author__ = 'sidya' class Service: - def __init__(self, jourService, moisService, anneeService, jourDemande, moisDemande, anneeDemande, rapport): - try: - dateService = datetime.date(anneeService, moisService, jourService) - self.dateService = dateService - except: - # Si la date n'est pas un nombre ou bien si ceux ci sont abérrents - print("la date de service n\'est pas correcte") - try: - dateDemande = datetime.date(anneeDemande, moisDemande, jourDemande) - self.dateDemande = dateDemande - except: - print("la date de service n\'est pas correcte") - self.rapport = rapport - - def enregistrerService(self, idClient, categorie, etat): - try: - connection = connexionBDD() - # 1.obtenir id service (fonction max de sqlite ne marche pas bien...elle ne prend en compte que le premier chiffre. Ex: max(56,9)= 9... ) - connection.cur.execute("SELECT count(service.idSercice) FROM service;") - # entrée dans la base de donnée - indiceidSer = connection.cur.execute("SELECT count(service.idService) FROM service;") - idService = int(''.join(map(str, indiceidSer))) + 1 - #2. obtenir l'idClient: définir une variable globale lors de l'execution du "jeu" - #3.Obtenir l'idVoiturier: en recherchant celui qui est disponible le jour en question - jour = calendar.weekday(self.dateService._day, self.dateService._month, self.dateService._year) - indiceVoiturier = connection.cur.execute( - "SELECT voiturier.idVoiturier FROM voiturier WHERE voiturier.joursDisponible = ?; ", (jour)) - idVoiturier = int(''.join(map(str, indiceVoiturier))) - connection.cur.execute( - "INSERT INTO service (idService,dateService,dateDemande,rapport,idClient,idVoiturier,idService, idVoiturier, categorie, etat) VALUES (?,?,?,?,?,?,?,?,?,?);", - (idService, self.dateService, self.dateDemande, self.rapport, idClient, idVoiturier, idService, - categorie, etat)) - connection.seDeconnecter() - return idService - except Exception as e: - print - str(e) - pass - - - - + pass \ No newline at end of file diff --git a/src/m/TypeAbonnement.py b/src/m/TypeAbonnement.py deleted file mode 100644 index 505824f..0000000 --- a/src/m/TypeAbonnement.py +++ /dev/null @@ -1,6 +0,0 @@ -__author__ = 'sidya' - - -class TypeAbonnement: - ABONNE = 0 - SUPER_ABONNE = 1 diff --git a/src/m/TypePlace.py b/src/m/TypePlace.py deleted file mode 100644 index f3e017f..0000000 --- a/src/m/TypePlace.py +++ /dev/null @@ -1,24 +0,0 @@ -__author__ = 'sidya' - - -class TypePlace: - """ - Classe qui permet de définir un type de place - """ - - def __init__(self, h, l, nb): - self.__hauteur = h - self.__longueur = l - self.__nb = nb - - @property - def hauteur(self): - return self.__hauteur - - @property - def longueur(self): - return self.__longueur - - @property - def nb(self): - return self.__nb diff --git a/src/m/Voiture.py b/src/m/Voiture.py index 4764826..3ac4fd5 100644 --- a/src/m/Voiture.py +++ b/src/m/Voiture.py @@ -1,26 +1,57 @@ -class Voiture(): - def __init__(self, longueur, hauteur, imma): - self._hauteur = hauteur - self._longueur = longueur - self._immatriculation = imma - self._estDansParking = False +from src.m.connexionBDD import connexionBDD + +__author__ = 'sidya' + +class Voiture: + @staticmethod + def get(id): + c = connexionBDD() + r = c.execute("SELECT * FROM voiture WHERE idVoiture='"+str(id)+"'") + row = r.fetchone() + if row is None : + raise IndexError("Invalid id") + c.seDeconnecter() + return Voiture(id,row["longueur"],row["hauteur"],row["imma"], bool(row["estDansParking"])) + + + def __init__(self, longueur, hauteur, imma, estDansParking): + self.__longueur = longueur + self.__hauteur = hauteur + self.__imma = imma + self.__estDansParking = estDansParking + + if id is None : + c = connexionBDD() + c.execute("INSERT INTO voiture (longueur,hauteur,imma, estDansParking) VALUES (?,?,?,?)", + (self.__longueur, self.__hauteur, self.__imma, int(self.__estDansParking))) + self.__id = c.lastId() + c.seDeconnecter() + else: + self.__id = id @property - def getHauteur(self): - return self._hauteur + def id(self): + return self.__id @property - def getLongueur(self): - return self._longueur + def hauteur(self): + return self.__hauteur @property - def getImmatriculation(self): - return self._immatriculation + def longueur(self): + return self.__longueur + + @property + def immatriculation(self): + return self.__immatriculation @property def estDansParking(self): - return self._estDansParking == True - - # def addPlacement(self, placement): - + return self.__estDansParking == True + def __str__(self): + return "[Voiture :" \ + " longueur = " +self.__longueur + ", " \ + " hauteur = " +self.__hauteur + ", " \ + " imma = " +self.__imma + ", " \ + " estDansParking = " +self.__estDansParking + "]" \ No newline at end of file diff --git a/src/m/Voiturier.py b/src/m/Voiturier.py deleted file mode 100644 index 3f3d643..0000000 --- a/src/m/Voiturier.py +++ /dev/null @@ -1,28 +0,0 @@ -import time - -from src.m.connexionBDD import connexionBDD - - -class Voiturier: - def __init__(self, id, nom, prenom): - self.numero = id - self.nom = nom - self.prenom = prenom - - def enregistrerVoiturier(self, nom, prenom, dateEmbauche): - connexion = connexionBDD() - # entrée dans la base de donnée - indiceidVoiturier = connexion.cur.execute("SELECT count(voiturier.idVoiturier) FROM voiturier;") + 1 - idVoiturier = int(''.join(map(str, indiceidVoiturier))) + 1 - connexion.cur.execute("INSERT INTO voiturier (idVoiturier,nom, prenom, dateEmbauche) VALUES (?,?,?,?);", - (self.idVoiturier, nom, prenom, dateEmbauche)) - connexion.seDeconnecter() - - def livrerVoiture(self): - dateJour = time.strptime() - connexion = connexionBDD() - indiceLivraison = connexion.cur.execute("SELECT count(voiturier.idVoiturier) FROM voiturier;") - idLivraison = int(''.join(map(str, indiceLivraison))) + 1 - connexion.cur.execute("INSERT INTO livraison (idLivraison,dateLivraison, idVoiturier) VALUES (?,?,?,?);", - (idLivraison, dateJour, self.idVoiturier)) - connexion.seDeconnecter() diff --git a/src/m/connexionBDD.py b/src/m/connexionBDD.py index e360b39..6546a4c 100644 --- a/src/m/connexionBDD.py +++ b/src/m/connexionBDD.py @@ -1,12 +1,32 @@ -import sqlite3 +__author__ = 'sidya' +import sqlite3 class connexionBDD: def __init__(self): - self.chemin = "BDDprojetPython.sq3" - self.conn = sqlite3.connect(self.chemin) - self.cur = self.conn.cursor() + self.__chemin = "m/BDDprojetPython.sq3" + self.__conn = sqlite3.connect(self.__chemin) + self.__conn.row_factory = sqlite3.Row + self.__cur = self.__conn.cursor() + + def execute(self, req, param = ()): + r = None + #try: + r = self.__cur.execute(req, param) + self.__conn.commit() + """except Exception as e: + print (e)""" + return r + + def lastId(self): + return self.__cur.lastrowid def seDeconnecter(self): - self.cur.close() - self.conn.close() \ No newline at end of file + self.__cur.close() + self.__conn.close() + + def initialisationBDD(self): + with open("m/table.sql") as f: + sql = f.read() + self.__conn.executescript(sql) + self.__conn.commit() diff --git a/src/m/table.sql b/src/m/table.sql index 357e16b..3c15ed4 100644 --- a/src/m/table.sql +++ b/src/m/table.sql @@ -1,27 +1,75 @@ +DROP TABLE IF EXISTS service; +DROP TABLE IF EXISTS contrat; +DROP TABLE IF EXISTS client; +DROP TABLE IF EXISTS abonnement; +DROP TABLE IF EXISTS placement; +DROP TABLE IF EXISTS voiture; +DROP TABLE IF EXISTS place; +DROP TABLE IF EXISTS parking; +DROP TABLE IF EXISTS typePlace; + + + CREATE TABLE parking ( - id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, - nom VARCHAR(30), + idParking INTEGER PRIMARY KEY , + nom VARCHAR(30) ); -CREATE TABLE place ( - id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, - idParking INT UNSIGNED FOREIGN KEY, - idType INT UNSIGNED FOREIGN KEY, - niveau INT UNSIGNED, - numero INT UNSIGNED -); CREATE TABLE typePlace ( - id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, - longueur INT UNSIGNED, - hauteur INT UNSIGNED, - largeur INT UNSIGNED, - estLibre INT(1), - estSuperAbo int(1) + idTypePlace INTEGER PRIMARY KEY , + longueur INTEGER , + hauteur INTEGER , + nombre INTEGER ); +CREATE TABLE place ( + idPlace INTEGER PRIMARY KEY , + idParking INTEGER , + idTypePlace INTEGER , + niveau INTEGER , + numero INTEGER , + estLibre INTEGER(1), + estSuperAbo INTEGER(1), + FOREIGN KEY (idParking) REFERENCES parking(id), + FOREIGN KEY (idTypePlace) REFERENCES typePlace(id) +); + +CREATE TABLE voiture ( + idVoiture INTEGER PRIMARY KEY , + hauteur INTEGER , + longueur INTEGER , + imma VARCHAR(10), + estDansParking INTEGER(1) +); CREATE TABLE placement ( + idPlacement VARCHAR(10) PRIMARY KEY , + idVoiture INTEGER , + idPlace INTEGER , + debut DATE, + fin DATE, + FOREIGN KEY (idVoiture) REFERENCES voiture(id), + FOREIGN KEY (idPlace) REFERENCES place(id) +); + +CREATE TABLE client ( + idClient VARCHAR(10) PRIMARY KEY , + nom VARCHAR(20), + prenom VARCHAR(20), + adresse VARCHAR(50), + typeAbonnement INTEGER +); + + +CREATE TABLE service ( + idService INTEGER PRIMARY KEY , + idClient VARCHAR(10), + dateDemande DATE, + dateService DATE, + dateRealisation DATE, + rapport VARCHAR(255), + FOREIGN KEY (idClient) REFERENCES client(id) ); \ No newline at end of file diff --git a/src/m/test/TestParking.py b/src/m/test/TestParking.py deleted file mode 100644 index d8f82f4..0000000 --- a/src/m/test/TestParking.py +++ /dev/null @@ -1,16 +0,0 @@ -__author__ = 'sidya' - -from nose.tools import assert_equal - -from src.m.Parking import Parking - - -class TestParking: - def recherchePlace(self): - """ - Test d'attribution des places - """ - p = Parking() - assert_equal() - - diff --git a/src/m/test/TestPlace.py b/src/m/test/TestPlace.py deleted file mode 100644 index 77fff2d..0000000 --- a/src/m/test/TestPlace.py +++ /dev/null @@ -1,5 +0,0 @@ -__author__ = 'sidya' - - -class TestPlace: - pass diff --git a/src/m/test/__init__.py b/src/m/test/__init__.py deleted file mode 100644 index 934a683..0000000 --- a/src/m/test/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__author__ = 'sidya' diff --git a/src/m/test/test.py b/src/m/test/test.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/m/test/testClient.py b/src/m/test/testClient.py deleted file mode 100644 index 3835ffd..0000000 --- a/src/m/test/testClient.py +++ /dev/null @@ -1,14 +0,0 @@ -__author__ = 'nadiel' - - -class testClient: - # def testsAbonner: - - def testnouvelleVoiture(self): - assert () - #v = Voiture() - - - #def testTailleMax(self): - # c = Camera() - # assert (c.capturerHauteur()>1.5) \ No newline at end of file diff --git a/src/m/test/testPlacement b/src/m/test/testPlacement deleted file mode 100644 index 76d4be7..0000000 --- a/src/m/test/testPlacement +++ /dev/null @@ -1,5 +0,0 @@ -from src.m.placement import Placement -class testPlacement: - def test_init(self): - newPlacement = Placement() - \ No newline at end of file diff --git a/src/m/test/testService.py b/src/m/test/testService.py deleted file mode 100644 index 4ac3834..0000000 --- a/src/m/test/testService.py +++ /dev/null @@ -1,7 +0,0 @@ -class testService: - """Fonction qui vérifie si la date insérée cest dans un format correcte (année est égale à l'année courante, 01≤jour≤31 et 01≤mois≤12); renvoie une erreur sinon""" - - -def testFormatDate(self, jourInsere, moisInsere, anneeInsere): - - diff --git a/src/v/Camera.py b/src/v/Camera.py index 8f776e9..1dcd918 100644 --- a/src/v/Camera.py +++ b/src/v/Camera.py @@ -12,5 +12,5 @@ class Camera: def donnerVoiture(self): v = Voiture(random.randint(150, 300), random.randint(100, 200), ''.join( random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in - range(random.randint(1, 10)))) + range(random.randint(1, 10))),False) return v diff --git a/src/v/MyQWidget.py b/src/v/MyQWidget.py index 7e5f0f2..c183d21 100644 --- a/src/v/MyQWidget.py +++ b/src/v/MyQWidget.py @@ -18,4 +18,5 @@ class MyQWidget(QtGui.QWidget): if result == QtGui.QMessageBox.Yes: event.accept() - self.__main.showWindow() \ No newline at end of file + self.__main.showWindow() + self.w = QtGui.QWidget \ No newline at end of file diff --git a/src/v/Ui_Service.py b/src/v/Ui_Service.py new file mode 100644 index 0000000..697f22e --- /dev/null +++ b/src/v/Ui_Service.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'service.ui' +# +# Created: Mon Jan 12 17:07:46 2015 +# by: PyQt4 UI code generator 4.11.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) + +class Ui_Service(object): + def setupUi(self, Service): + Service.setObjectName(_fromUtf8("Service")) + Service.resize(469, 221) + self.btn_valider = QtGui.QPushButton(Service) + self.btn_valider.setGeometry(QtCore.QRect(260, 180, 87, 27)) + self.btn_valider.setObjectName(_fromUtf8("btn_valider")) + self.dateTimeEdit = QtGui.QDateTimeEdit(Service) + self.dateTimeEdit.setGeometry(QtCore.QRect(330, 60, 121, 23)) + self.dateTimeEdit.setObjectName(_fromUtf8("dateTimeEdit")) + self.btn_annuler = QtGui.QPushButton(Service) + self.btn_annuler.setGeometry(QtCore.QRect(120, 180, 87, 27)) + self.btn_annuler.setObjectName(_fromUtf8("btn_annuler")) + self.formLayoutWidget = QtGui.QWidget(Service) + self.formLayoutWidget.setGeometry(QtCore.QRect(160, 60, 160, 41)) + self.formLayoutWidget.setObjectName(_fromUtf8("formLayoutWidget")) + self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) + self.formLayout.setMargin(0) + self.formLayout.setObjectName(_fromUtf8("formLayout")) + self.lieuLabel = QtGui.QLabel(self.formLayoutWidget) + self.lieuLabel.setObjectName(_fromUtf8("lieuLabel")) + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.lieuLabel) + self.lieuLineEdit = QtGui.QLineEdit(self.formLayoutWidget) + self.lieuLineEdit.setObjectName(_fromUtf8("lieuLineEdit")) + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.lieuLineEdit) + self.widget = QtGui.QWidget(Service) + self.widget.setGeometry(QtCore.QRect(50, 50, 109, 121)) + self.widget.setObjectName(_fromUtf8("widget")) + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.checkBox_Livraison = QtGui.QCheckBox(self.widget) + self.checkBox_Livraison.setObjectName(_fromUtf8("checkBox_Livraison")) + self.verticalLayout.addWidget(self.checkBox_Livraison) + self.checkBox_Maintenance = QtGui.QCheckBox(self.widget) + self.checkBox_Maintenance.setObjectName(_fromUtf8("checkBox_Maintenance")) + self.verticalLayout.addWidget(self.checkBox_Maintenance) + self.checkBox_Entretien = QtGui.QCheckBox(self.widget) + self.checkBox_Entretien.setObjectName(_fromUtf8("checkBox_Entretien")) + self.verticalLayout.addWidget(self.checkBox_Entretien) + + self.retranslateUi(Service) + QtCore.QMetaObject.connectSlotsByName(Service) + + def retranslateUi(self, Service): + Service.setWindowTitle(_translate("Service", "Form", None)) + self.btn_valider.setText(_translate("Service", "Valider", None)) + self.btn_annuler.setText(_translate("Service", "Annuler", None)) + self.lieuLabel.setText(_translate("Service", "Lieu", None)) + self.checkBox_Livraison.setText(_translate("Service", "Livraison", None)) + self.checkBox_Maintenance.setText(_translate("Service", "Maintenance", None)) + self.checkBox_Entretien.setText(_translate("Service", "Entretien", None)) +