-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
116 lines (110 loc) · 4.95 KB
/
console.py
File metadata and controls
116 lines (110 loc) · 4.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from datetime import datetime
from Core.Database import Database
from models import *
if __name__ == "__main__":
db = Database()
#db.loadManga("import")
#db.loadTome("importTomes")
boucle = True
while(boucle):
print("Mode console")
print("1 - Create")
print("2 - Delete")
print("3 - Update")
print("4 - Quitter")
action = int(input("Saisir action ?"))
if action == 1:
print("Créer un objet")
print("1 - Manga")
print("2 - Tome")
print("3 - Commentaire")
action = int(input("Quel objet souhaitez vous créer"))
if action == 1:
titre = input("Titre ?")
description = input("Description ?")
editeur = input("Editeur ?")
scenariste = input("Scenariste ?")
dessinateur = input("Dessinateur ?")
statut = input("Statut ?")
genre = input("Genre ?")
manga = Manga(titre,description,editeur,scenariste,dessinateur,statut,genre)
db.create(manga, Manga)
if action == 2:
action = None
liste = db.retrieve(Manga)
for i in liste:
print(i)
manga = input("Id manga ?")
numero = input("Numero du tome ?")
date_parution = input("Date de parution ?")
# Simplification en mode console
date_achat = input("Date d'achat ?")
possede = bool(input("Tome dans ma collection ?"))
lu = bool(input("Tome lu ?"))
a_acheter = bool(input("Tome à acheter ?"))
prix = float(input("Prix du tome ?"))
couverture = input("Couverture du tome ?")
tome = Tome(manga, numero, date_parution, possede, lu, a_acheter, prix,couverture, date_achat)
db.createTome(tome)
if action == 3:
liste = db.retrieve(Manga)
for i in liste:
print(i)
id = int(input("Id manga ?"))
titre = input("Titre du commentaire manga ?")
commentaire = input("Commentaire sur le manga ?")
comment = Commentaire(commentaire,titre, id)
db.create(comment, Commentaire)
action = 0
if action == 2:
print("Choisissez ce que vous voulez supprimer ?")
print("1 - Manga")
print("2 - Tome")
action = int(input("Choix ?"))
if action == 1:
id = input("Id du manga a supprimer ?")
manga = db.retrieve(Manga, Manga.id, id)
if manga != None:
confirmation = bool(input("Voulez vous vraiment supprimer le manga {}, tous les tomes associé seront supprimés ?".format(manga.titre)))
if confirmation == True:
db.delete(manga, Manga)
if action == 2 :
manga = input("Id de la serie ?")
numero = input("Numéro du tome ?")
tome = db.retrieveTome(manga,numero)
if tome != None:
nom = db.retrieve(Manga, Manga.id, manga).titre
confirmation = bool(input("Voulez vous vraiment supprimer le tome {} de {} ?".format(numero, nom)))
if confirmation == True:
db.deleteTome(tome)
action = 0
if action == 3:
action = None
liste = db.retrieve(Manga)
for i in liste:
print(i)
id = input("Id manga ?")
commentaire = db.retrieve(Commentaire, Commentaire.id, id)
if commentaire != None:
nom = db.retrieve(Manga, Manga.id, id).titre
confirmation = bool(input("Voulez vous vraiment supprimer le commentaire sur le manga {} ?".format(nom)))
if confirmation == True:
db.delete(commentaire, Commentaire)
action = 0
if action == 3:
id = input("Id du manga a modifier ?")
manga = db.retrieve(Manga, Manga.id, id)
if manga != None:
#print(manga.titre)
manga.titre = input("Titre ?") or manga.titre
manga.description = bool(input("Résumé ?")) or manga.description
manga.editeur = input("Editeur ?") or manga.editeur
manga.scenariste = input("Scenariste ?") or manga.scenariste
manga.dessinateur = input("Dessinateur ?") or manga.dessinateur
manga.statut = input("Statut ?") or manga.statut
manga.genre = input("Genre ?") or manga.genre
db.update()
print(db.retrieve(Manga, Manga.id, manga.id))
action = 0
if action == 4:
boucle = False