refonte
This commit is contained in:
112
src/c/Borne.py
112
src/c/Borne.py
@@ -1,10 +1,9 @@
|
||||
from PyQt4 import QtGui
|
||||
from src.c.SelectService import SelectService
|
||||
|
||||
from src.c.Teleporteur import Teleporteur
|
||||
from src.m.Parking import Placement
|
||||
from src.m.Client import Client
|
||||
from src.m.Service import Service
|
||||
from src.m.Service import Service, TypeService
|
||||
from src.m.Client import TypeAbonnement
|
||||
from src.v.Camera import Camera
|
||||
from src.v.MyQWidget import MyQWidget
|
||||
@@ -16,8 +15,12 @@ __author__ = 'sidya'
|
||||
|
||||
class Borne:
|
||||
"""
|
||||
Controleur de la vue de la borne permettant l'accès au parking
|
||||
Controleur de la vue des bornes permettant l'accès au parking
|
||||
"""
|
||||
bornes = []
|
||||
@staticmethod
|
||||
def MajBornes():
|
||||
pass
|
||||
|
||||
def __init__(self, main, parking):
|
||||
self.__parking = parking
|
||||
@@ -41,29 +44,54 @@ class Borne:
|
||||
# Validator
|
||||
|
||||
|
||||
self.__ui.label_aff.setText("Dream park")
|
||||
self.__ui.nomParking.setText(parking.nom)
|
||||
|
||||
self.__ui.label_aff.setStyleSheet("qproperty-alignment: AlignCenter; font-size: 28px")
|
||||
self.__ui.nomParking.setStyleSheet("qproperty-alignment: AlignCenter; font-size: 28px")
|
||||
self.nonVoiture()
|
||||
self.showWindow()
|
||||
self.__ui.nomParking.setText("Borne " + str(len(self.bornes)+1) + " - Parking : " +parking.nom)
|
||||
|
||||
|
||||
def blockAll(self):
|
||||
self.__ui.box_abo.setDisabled(True)
|
||||
self.__ui.box_garer.setDisabled(True)
|
||||
self.__ui.box_id.setDisabled(True)
|
||||
self.__ui.box_recup.setDisabled(True)
|
||||
|
||||
self.__ui.btn_Voiture.setDisabled(True)
|
||||
self.__ui.btn_annuler.setDisabled(True)
|
||||
self.__ui.btn_desabo.setDisabled(True)
|
||||
|
||||
def nonVoiture(self):
|
||||
"""
|
||||
Met en etat initial de départ sans voiture
|
||||
:return:
|
||||
"""
|
||||
self.__ui.label_aff.setText("Dream park")
|
||||
self.__c = None
|
||||
self.__ui.box_abo.setDisabled(True)
|
||||
self.__ui.box_garer.setDisabled(True)
|
||||
self.__ui.box_id.setDisabled(True)
|
||||
self.__ui.box_recup.setDisabled(False)
|
||||
self.__ui.box_service.setDisabled(True)
|
||||
self.__ui.btn_Voiture.setDisabled(False)
|
||||
self.__ui.btn_desabo.setDisabled(True)
|
||||
|
||||
self.__ui.nomLineEdit.setText("")
|
||||
self.__ui.prenomLineEdit.setText("")
|
||||
self.__ui.numeroCarteLineEdit.setText("")
|
||||
self.__ui.checkBox.setChecked(False)
|
||||
self.__ui.lineEdit_id.setText("")
|
||||
self.__ui.numeroTicketLineEdit.setText("")
|
||||
self.__ui.labIdClient.setText("Non identifier")
|
||||
|
||||
def newVoiture(self):
|
||||
"""
|
||||
Meten etat d'arrive de voiture detecte par la camera
|
||||
:return:
|
||||
"""
|
||||
self.v_actuel = Camera.donnerVoiture()
|
||||
self.__ui.btn_Voiture.setDisabled(True)
|
||||
self.__v_actuel = Camera.donnerVoiture()
|
||||
self.__ui.box_abo.setDisabled(False)
|
||||
self.__ui.box_garer.setDisabled(False)
|
||||
self.__ui.box_id.setDisabled(False)
|
||||
@@ -76,18 +104,20 @@ class Borne:
|
||||
Gestion de l'identification a partir d'un abo a partir de son id (lineedit)
|
||||
:return:
|
||||
"""
|
||||
self.__c = Client.get(self.__ui.lineEdit_id.text())
|
||||
if self.__c != None:
|
||||
try :
|
||||
self.__c = Client.get(self.__ui.lineEdit_id.text())
|
||||
self.__ui.label_aff.setText("Bonjour " + str(self.__c.nom) + " " + str(self.__c.prenom))
|
||||
# self.__ui.labIdClient.setText(str(self.__c))
|
||||
self.__ui.labIdClient.setText("Vous étes identifier")
|
||||
self.__ui.box_id.setDisabled(True)
|
||||
else:
|
||||
self.__ui.box_service.setDisabled(False)
|
||||
self.__ui.btn_desabo.setDisabled(False)
|
||||
except IndexError :
|
||||
self.__ui.label_aff.setText("Echec identification")
|
||||
self.__ui.labIdClient.setText("Non identifier")
|
||||
|
||||
def abo(self):
|
||||
"""
|
||||
Gestion validation formaulaire d'abonnement
|
||||
Gestion validation formulaire d'abonnement
|
||||
:return:
|
||||
"""
|
||||
if self.__c != None:
|
||||
@@ -99,16 +129,17 @@ class Borne:
|
||||
else:
|
||||
if self.__ui.checkBox.isChecked():
|
||||
self.__c = Client(None,
|
||||
self.__ui.nomLineEdit,
|
||||
self.__ui.prenomLineEdit,
|
||||
str(self.__ui.nomLineEdit.text()),
|
||||
str(self.__ui.prenomLineEdit.text()),
|
||||
"",
|
||||
TypeAbonnement.SUPER_ABONNE)
|
||||
else:
|
||||
self.__c = Client(None,
|
||||
self.__ui.nomLineEdit,
|
||||
self.__ui.prenomLineEdit,
|
||||
str(self.__ui.nomLineEdit.text()),
|
||||
str(self.__ui.prenomLineEdit.text()),
|
||||
"",
|
||||
TypeAbonnement.ABONNE)
|
||||
print(self.__c)
|
||||
self.__ui.label_aff.setText("Votre id membre est : " + self.__c.id)
|
||||
self.__ui.lineEdit_id.setText(self.__c.id)
|
||||
self.identification()
|
||||
@@ -118,27 +149,29 @@ class Borne:
|
||||
Gestion de la validation de garer son vehicule
|
||||
:return:
|
||||
"""
|
||||
id = None
|
||||
if self.__c is None:
|
||||
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()
|
||||
p = self.__parking.recherchePlace(self.__v_actuel)
|
||||
if p is not None:
|
||||
id = Teleporteur.teleporterVoiture(self.__v_actuel, p)
|
||||
else:
|
||||
if self.__c.abonnement != TypeAbonnement.SUPER_ABONNE:
|
||||
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()
|
||||
p = self.__parking.recherchePlace(self.__v_actuel)
|
||||
if p is not None :
|
||||
id = Teleporteur.teleporterVoiture(self.__v_actuel, p)
|
||||
if self.__ui.checkBox_Livraison_2.isChecked():
|
||||
Service(None, self.__c, p, TypeService.LIVRAISON)
|
||||
if self.__ui.checkBox_Entretien_2.isChecked():
|
||||
Service(None, self.__c, p, TypeService.ENTRETIEN)
|
||||
if self.__ui.checkBox_Maintenance_2.isChecked():
|
||||
Service(None, self.__c, p, TypeService.MAINTENANCE)
|
||||
else:
|
||||
Teleporteur.teleporterVoitureSuperAbonne(self.v_actuel)
|
||||
Teleporteur.teleporterVoitureSuperAbonne(self.__v_actuel)
|
||||
if id is not None:
|
||||
self.nonVoiture()
|
||||
self.ticketDepot(id)
|
||||
else:
|
||||
self.__ui.label_aff.setText("Aucune Place Disponible Pour Votre Véhicule. Devenez Super Abonné!")
|
||||
|
||||
|
||||
def recuperer(self):
|
||||
@@ -149,11 +182,22 @@ class Borne:
|
||||
try :
|
||||
p = Placement.get(self.__ui.numeroTicketLineEdit.text())
|
||||
Teleporteur.teleporterVersSortie(p)
|
||||
self.__ui.label_aff.setText("Bonne journée")
|
||||
self.nonVoiture()
|
||||
self.ticketDepot(id)
|
||||
except IndexError:
|
||||
self.__ui.label_aff.setText("Mauvais numero de ticket")
|
||||
|
||||
def ticketDepot(self, id):
|
||||
QtGui.QMessageBox.information(self.__w,
|
||||
"Ticket",
|
||||
"Votre numero ticket : " + str(id)
|
||||
)
|
||||
|
||||
def ticketRetrait(self):
|
||||
QtGui.QMessageBox.information(self.__w,
|
||||
"Ticket",
|
||||
"Merci de votre confiance! Bonne journée !"
|
||||
)
|
||||
|
||||
def showWindow(self):
|
||||
"""
|
||||
@@ -169,9 +213,9 @@ class Borne:
|
||||
Gestion de sortie de la vue borne
|
||||
:return:
|
||||
"""
|
||||
self.__w.hide()
|
||||
self.__main.showWindow()
|
||||
|
||||
|
||||
def error(self):
|
||||
"""
|
||||
Qdialog message erreur
|
||||
|
||||
@@ -65,7 +65,7 @@ class CreaParking:
|
||||
|
||||
if result == QtGui.QMessageBox.Yes:
|
||||
self._main.activity("Annulation Creation Parking", self._main.lvl.INFO)
|
||||
self._w.hide()
|
||||
#self._w.hide()
|
||||
self._main.showWindow()
|
||||
|
||||
def valider(self):
|
||||
@@ -76,9 +76,12 @@ class CreaParking:
|
||||
# try:
|
||||
l = []
|
||||
for i in range(0, self._ui.tableWidget.rowCount()):
|
||||
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)
|
||||
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()),
|
||||
float(self._ui.tableWidget.item(i, 3).text()),
|
||||
int(self._ui.tableWidget.item(i, 4).text())))
|
||||
p = Parking(None, self._ui.lineEdit_nom.text(), l)
|
||||
self._main.activity("Ajout:" + str(p), self._main.lvl.INFO)
|
||||
self._w.hide()
|
||||
self._main.showWindow()
|
||||
|
||||
@@ -22,9 +22,9 @@ class DetailsPlaces(CreaParking):
|
||||
|
||||
self._ui.lineEdit_nom.setDisabled(True)
|
||||
self._ui.tableWidget.setDisabled(True)
|
||||
self._ui.btn_annuler.setDisabled(True)
|
||||
self._ui.btn_addRow.setDisabled(True)
|
||||
self._ui.btn_rmRow.setDisabled(True)
|
||||
self._ui.btn_annuler.setVisible(False)
|
||||
self._ui.btn_addRow.setVisible(False)
|
||||
self._ui.btn_rmRow.setVisible(False)
|
||||
|
||||
def valider(self):
|
||||
self._w.hide()
|
||||
|
||||
@@ -7,7 +7,10 @@ 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.Service import Service
|
||||
from src.m.Parking import Parking
|
||||
from src.m.Service import TypeService
|
||||
from src.m.connexionBDD import connexionBDD
|
||||
from src.v.MyQMainWindow import MyQMainWindow
|
||||
from src.v.Ui_MainWindow import Ui_MainWindow
|
||||
|
||||
@@ -32,7 +35,11 @@ class Main:
|
||||
self.__ui.btn_creer.clicked.connect(self.creerParking)
|
||||
self.__ui.btn_supprimer.clicked.connect(self.rmParking)
|
||||
self.__ui.btn_details.clicked.connect(self.detailsPlacesParking)
|
||||
self.__ui.btn_borne.clicked.connect(self.afficherBorne)
|
||||
self.__ui.btn_borne.clicked.connect(self.afficherBornes)
|
||||
self.__ui.actionNouveau_2.triggered.connect(self.nouveau)
|
||||
self.__ui.actionSauvegarder.triggered.connect(self.sauver)
|
||||
self.__ui.actionCharger.triggered.connect(self.charger)
|
||||
self.__ui.actionQuitter.triggered.connect(self.quitter)
|
||||
|
||||
|
||||
|
||||
@@ -66,21 +73,40 @@ class Main:
|
||||
def majListeParking(self):
|
||||
self.__ui.comboBox.clear()
|
||||
self.__ui.comboBox.addItem("Selectionner un parking")
|
||||
for p in Parking.getAll():
|
||||
for p in Parking.getAllActif():
|
||||
self.__ui.comboBox.addItem(p.nom)
|
||||
|
||||
def selectParking(self):
|
||||
#onglet detail parking
|
||||
self.__ui.nom.clear()
|
||||
self.__ui.placesParNiveau.clear()
|
||||
self.__ui.placesDispo.clear()
|
||||
self.__ui.placesSuperAbo.clear()
|
||||
if self.__ui.comboBox.count() > 1:
|
||||
p = Parking.getAll()
|
||||
p = Parking.getAllActif()
|
||||
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(p[self.__ui.comboBox.currentIndex() - 1].nbPlacesLibresParking))
|
||||
self.__ui.placesSuperAbo.setText(str(p[self.__ui.comboBox.currentIndex() - 1].nbSuperAbo))
|
||||
self.__ui.btn_details.setDisabled(False)
|
||||
self.__ui.btn_supprimer.setDisabled(False)
|
||||
self.__ui.btn_borne.setDisabled(False)
|
||||
else:
|
||||
self.__ui.btn_details.setDisabled(True)
|
||||
self.__ui.btn_supprimer.setDisabled(True)
|
||||
self.__ui.btn_borne.setDisabled(True)
|
||||
|
||||
#onglet Service
|
||||
for s in Service.serviceEnCours:
|
||||
if s.typeService == TypeService.LIVRAISON :
|
||||
self.__ui.comboBox_livraison.addItem(str(s.id))
|
||||
if s.typeService == TypeService.ENTRETIEN :
|
||||
self.__ui.comboBox_entretien.addItem(str(s.id))
|
||||
if s.typeService == TypeService.MAINTENANCE :
|
||||
self.__ui.comboBox_maintenance.addItem(str(s.id))
|
||||
|
||||
#Onglet Stats
|
||||
|
||||
|
||||
def creerParking(self):
|
||||
@@ -98,23 +124,52 @@ class Main:
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
|
||||
if result == QtGui.QMessageBox.Yes:
|
||||
self.__parkings.remove(self.__parkings[self.__ui.comboBox.currentIndex() - 1])
|
||||
Parking.remove(Parking.parkings[self.__ui.comboBox.currentIndex() - 1])
|
||||
self.__view.hide()
|
||||
self.showWindow()
|
||||
|
||||
def detailsPlacesParking(self):
|
||||
if self.__ui.comboBox.currentIndex() != 0 :
|
||||
self.__view.hide()
|
||||
self.__widgetCourant = DetailsPlaces(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1])
|
||||
|
||||
def afficherBornes(self):
|
||||
if self.__ui.comboBox.currentIndex() != 0:
|
||||
self.__view.hide()
|
||||
self.__widgetCourant = DetailsPlaces(self, Parking.getAll()[self.__ui.comboBox.currentIndex() - 1])
|
||||
Borne.bornes.append(Borne(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1]))
|
||||
Borne.bornes.append(Borne(self, Parking.getAllActif()[self.__ui.comboBox.currentIndex() - 1]))
|
||||
|
||||
def afficherBorne(self):
|
||||
if self.__ui.comboBox.currentIndex() != 0:
|
||||
self.__view.hide()
|
||||
self.__widgetCourant = Borne(self, Parking.getAll()[self.__ui.comboBox.currentIndex() - 1])
|
||||
def nouveau(self):
|
||||
result = QtGui.QMessageBox.question(self.__view,
|
||||
"Confirmer Nouveau...",
|
||||
"Etes vous sur de vouloir supprimer ?\n"
|
||||
"(Toutes données non sauvegardées seront perdues)",
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
if result == QtGui.QMessageBox.Yes:
|
||||
c = connexionBDD()
|
||||
c.initialisationBDD()
|
||||
c.seDeconnecter()
|
||||
Parking.removeAllRam()
|
||||
self.majListeParking()
|
||||
|
||||
def charger(self):
|
||||
path = QtGui.QFileDialog.getOpenFileName(self.__view,"Charger",".")
|
||||
if path:
|
||||
connexionBDD.charger(path)
|
||||
self.majListeParking()
|
||||
|
||||
def sauver(self):
|
||||
path = QtGui.QFileDialog.getSaveFileName(self.__view,"Sauvegarder",".")
|
||||
if path:
|
||||
connexionBDD.sauver(path)
|
||||
self.majListeParking()
|
||||
|
||||
def quitter(self):
|
||||
self.__view.close()
|
||||
|
||||
def showWindow(self):
|
||||
self.majListeParking()
|
||||
self.__view.show()
|
||||
self.__widgetCourant = None # supprime eventuel widget
|
||||
Borne.bornes = []
|
||||
self.__view.focusWidget() # reprend le focus sur la fenetre principal
|
||||
@@ -1,55 +0,0 @@
|
||||
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()
|
||||
@@ -6,13 +6,16 @@ __author__ = 'sidya'
|
||||
class Teleporteur:
|
||||
@staticmethod
|
||||
def teleporterVoiture(voiture, place):
|
||||
p = Placement(None,voiture, place,None,None)
|
||||
p = Placement(None,voiture, place)
|
||||
place.prendre()
|
||||
return p.id
|
||||
|
||||
@staticmethod
|
||||
def teleporterVoitureSuperAbonne(voiture):
|
||||
pass
|
||||
def teleporterVoitureSuperAbonne(voiture, parking):
|
||||
place = parking.addPlaceSuperAbo()
|
||||
p = Placement(None, voiture, place)
|
||||
return p.id
|
||||
|
||||
@staticmethod
|
||||
def teleporterVersSortie(placement):
|
||||
placement.end()
|
||||
placement.end()
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
__author__ = 'sidya'
|
||||
|
||||
|
||||
class TestAcces:
|
||||
pass
|
||||
@@ -1,5 +0,0 @@
|
||||
__author__ = 'sidya'
|
||||
|
||||
|
||||
class TestTeleporteur:
|
||||
pass
|
||||
@@ -1 +0,0 @@
|
||||
__author__ = 'sidya'
|
||||
Reference in New Issue
Block a user