From b3fdd4727f15abf2dea3390f6402f3d58cc00b14 Mon Sep 17 00:00:00 2001 From: Simon <levionnois@et.esiea.fr> Date: Sat, 23 Apr 2022 17:50:31 +0200 Subject: [PATCH 1/4] User_DAO + User_Model User_DAO + User_Model Fonctionnel --- controller/user_controller.py | 44 +++++++++++++++++++++++-- model/dao/user_dao.py | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/controller/user_controller.py b/controller/user_controller.py index 52600f5..98051b1 100644 --- a/controller/user_controller.py +++ b/controller/user_controller.py @@ -5,5 +5,45 @@ from model.mapping.user import User class UserController: - def __init(self, database_session): - self.database_session = database_session \ No newline at end of file + def __init__(self, database_session): + self.database_session = database_session + + def get(self,id): + searched_user=user_dao.UserDAO.get(id) + return searched_user + + def get_by_name(self, firstname, lastname,database_session): + member = user_dao.UserDAO(database_session).get_by_name(firstname,lastname) + return member + + def get_by_name_and_mail(self, firstname, email, database_session): + member = user_dao.UserDAO(database_session).get_by_name_and_mail(firstname, email) + return member + + def get_user_type(self, user): #Renvoi 0 si Client, 1 si Vendeur, 2 si Admin, -1 si erreur + if (user.type == "Client"): + return 0 + elif (user.type == "Seller"): + return 1 + elif (user.type == "Admin"): + return 2 + else: + return -1 + + + def delete(self,entity,database_session): + user_dao.UserDAO(database_session).delete(entity) + + def get_all(self, database_session): + list=user_dao.UserDAO(database_session).get_all() + return list + def update(self, member: User, data: dict, session): + try: + searched_user= user_dao.UserDAO(session).update(member, data) + return searched_user + except: + print("erreur dans la mis a jour de l'utilisateur") + + def add(self, data:dict): + added_user=user_dao.UserDAO(self.database_session).create(data) + return added_user \ No newline at end of file diff --git a/model/dao/user_dao.py b/model/dao/user_dao.py index 32cf80e..9fc7685 100644 --- a/model/dao/user_dao.py +++ b/model/dao/user_dao.py @@ -13,3 +13,63 @@ class UserDAO(DAO): def __init__(self, database_session): #intialize from mother class super().__init__(database_session) + + def get(self, id): + try: + return self._database_session.query(User).filter_by(id=id).order_by(User.firstname).one() + except NoResultFound: + raise ResourceNotFound() + + def get_all(self): + try: + return self._database_session.query(User).order_by(User.firstname).all() + except NoResultFound: + raise ResourceNotFound() + + def get_by_name_and_mail(self, firstname: str, email: str): + try: + return self._database_session.query(User).filter_by(firstname=firstname, email=email)\ + .order_by(User.firstname).one() + except NoResultFound: + raise ResourceNotFound() + + + def get_by_name(self, firstname: str, lastname: str): + try: + return self._database_session.query(User).filter_by(firstname=firstname, lastname=lastname)\ + .order_by(User.firstname).one() + except NoResultFound: + raise ResourceNotFound() + + def create(self, data: dict): + try: + id = str(uuid.uuid4()) + member = User(firstname=data.get('firstname'), lastname=data.get('lastname'), email=data.get('email'), phone=data.get('phone'), type=data.get('type')) + self._database_session.add(member) + self._database_session.commit() + self._database_session.flush() + except IntegrityError: + raise Error("Member already exists") + return member + + def update(self, member: User, data: dict): + if 'firstname' in data: + member.firstname = data['firstname'] + if 'lastname' in data: + member.lastname = data['lastname'] + if 'email' in data: + member.email = data['email'] + if 'type' in data: + member.type = data['type'] + try: + self._database_session.merge(member) + self._database_session.flush() + except IntegrityError: + raise Error("Error data may be malformed") + return member + + def delete(self, entity): + try: + self._database_session.delete(entity) + except SQLAlchemyError as e: + raise Error(str(e)) \ No newline at end of file -- GitLab From b2e97bbb9ac2be6892fae9e359eb3dd8be54282a Mon Sep 17 00:00:00 2001 From: Simon <levionnois@et.esiea.fr> Date: Sat, 7 May 2022 15:25:02 +0200 Subject: [PATCH 2/4] Final User in Terminal View Complete Library for User Database in Terminal View --- .../user_controller.cpython-39.pyc | Bin 652 -> 2024 bytes controller/user_controller.py | 51 ++++----- main.py | 7 +- .../__pycache__/advertise_dao.cpython-39.pyc | Bin 857 -> 856 bytes model/dao/__pycache__/user_dao.cpython-39.pyc | Bin 832 -> 2872 bytes model/dao/advertise_dao.py | 4 +- model/dao/user_dao.py | 6 +- model/mapping/__pycache__/user.cpython-39.pyc | Bin 1146 -> 1145 bytes my_app.db | Bin 0 -> 28672 bytes view/__pycache__/terminal_view.cpython-39.pyc | Bin 0 -> 1668 bytes view/__pycache__/user_view.cpython-39.pyc | Bin 628 -> 3439 bytes view/__pycache__/window_view.cpython-39.pyc | Bin 666 -> 805 bytes view/terminal_view.py | 52 +++++++++ view/user_view.py | 102 +++++++++++++++++- view/window_view.py | 9 +- 15 files changed, 193 insertions(+), 38 deletions(-) create mode 100644 my_app.db create mode 100644 view/__pycache__/terminal_view.cpython-39.pyc create mode 100644 view/terminal_view.py diff --git a/controller/__pycache__/user_controller.cpython-39.pyc b/controller/__pycache__/user_controller.cpython-39.pyc index 6818763aef5526740127dcea439a4661aeebc7b1..b25f10d966bd14d60cd0d4cb77d79c02765c206d 100644 GIT binary patch literal 2024 zcmZ`)&2A$_5bo~zwPTxLR=e5NB8)(SLC9i3;(!n$N?<R@APhn~vecTmdy~ob%$S}r zD3<rMd5k^8$2`ZrMT;A!JOF2?YX8O#ZB0$rbamJFRaKXhX0uLU9FP7u`O72ZZ&Wsi z1IoAXlwX1nL{LRC8dHjMrda00j-5No&Aiy7<S7xZ@Ggn)Ua{C0exF3a4eTWmH9=pN zWm@Dg4acR_TqFg|-CtooM4QdA^87P=l_aKu#7t1ZE=lZ2S2(Y!_2kB$@I?S$eG!Tp zyaO4+di^yMd!lja#x>CtE%;s+Z;5?)?}@hoRok@C?@^Igx=;!bunqS($L9#15<@hl zQ^J9DpIp-(fZi8Lm7FA{<mG}CGj1u>a~**7HPJPA{gZ$=`f7lV%0WNPihOV^%NJEK z8hjx$**VPfH`j9T^v!ji%FYkPX*x`$8vLY-b6I_#=7}17@TB`>FkGP=*ubsz?&!jV zoTqtOaUO!Z($b)l2e;XEmo^x1#D0q|2HQuhc)+J1CI=O{0?OxXMz5SHoza(U%6<d- z)c&49DfG!_HXsq}O&)%yb)h?do~2555+Tz3w3BoYLgZ>Z-2|u{AO2|LWBj3(NhKpk zBWB$|i#qI+f+Im2y}7{Pn*f$@{~jnd9fUI4rat^8_i<sJ#_qy&haaM_{Ms<F?10r3 zn-OHzCmQ(!9yHTU5GFX46;G5}g2cp{I>IZtO3P{+<Q~``Dur-L^ijGX2yM~Hqb-OV zhC^$FhA`j;64Wis`!KOE9fS$>$7bxMJ9Y1ZdJmzVT<|=}Bu{d|vm{lKXM<~M&r@Ai zxMVzu3yTzFGCSD~^#L4(aCeSFJPS%~I{9dq(w(~^rXRpYo8cX<tCIU1Oco`##dckC zl_TgY=seFz&enzZ?q=bQM^M>VdexcijDf_W_~!Za?J@*mq|>}wL}!i81dE#-H%po5 z;o1MxVtsxLvVDXhu?=)xjt{p2v$h^$X)OoN@v*7C2NRoWyls%`nQgFlCE6EK$<@6v zzRat%y08h|F30-Z6ydxN=P&!hHomphts8Tz0b+Wl^c?Q|3#MBFZj03%&>jmYNUM3E zeS!^N1n@woh{B%nk5md6HH8z5-<Q~EZ>-`SiY(1<(9g}kFt9IG7b6J;gDt_hn7?gK zHDtqo0kaRmrfh*Av`*dS!zKq?;a_d&MGb6}_J(j%=R7OKSV_)JgY)0ViJGt276TnJ z9aefDPS@|CI6#3nQ$I%W9*U1qV3*$zSPL3&F;=#P7qZZ41)&?d`$6c~wO$mM7I>Gc zyZjT;7zR^Yek|rKvpv_dWHf@J?%IG@5a?mUs|8{EWcc-*)i)U85<xUrgErWI?DEsQ delta 229 zcmaFC-^0q6$ji&c00f^F1|&UZn8??w%mm~)0CBMhkVs{SVoYI(VoG65VQOKBVoqTW zX3%7r_{V}#bFwL;JTDti%}RzM4j}b4X>uZ?GmBGVaq8sdjB>hBZ1M4#d6^|3xnhu^ z42)Hxp~b01&iQ#IMfo{7sYQAa6@Hp5li#taSVxJ*qsl|1!KNb-oIs<BSb+q{a<Iu9 TOp^=PeFQ)@A*-8whFt~#L}N4h diff --git a/controller/user_controller.py b/controller/user_controller.py index 98051b1..6dacf40 100644 --- a/controller/user_controller.py +++ b/controller/user_controller.py @@ -7,20 +7,33 @@ class UserController: def __init__(self, database_session): self.database_session = database_session + + def addUser(self, data:dict): + try : + added_user=user_dao.UserDAO(self.database_session).create(data) + return added_user + except: + return "Error while adding a User" - def get(self,id): - searched_user=user_dao.UserDAO.get(id) - return searched_user + def getAllUsers(self, database_session): + users_list=user_dao.UserDAO(database_session).get_all() + return users_list - def get_by_name(self, firstname, lastname,database_session): - member = user_dao.UserDAO(database_session).get_by_name(firstname,lastname) - return member - - def get_by_name_and_mail(self, firstname, email, database_session): + def getUser_by_name_and_mail(self, firstname, email, database_session): member = user_dao.UserDAO(database_session).get_by_name_and_mail(firstname, email) return member + + def updateUser(self, member: User, data: dict, session): + try: + searched_user= user_dao.UserDAO(session).update(member, data) + return searched_user + except: + print("Error while updating the user") + + def deleteUser(self,entity,database_session): + user_dao.UserDAO(database_session).delete(entity) - def get_user_type(self, user): #Renvoi 0 si Client, 1 si Vendeur, 2 si Admin, -1 si erreur + def User_Type(self, user): #Renvoi 0 si Client, 1 si Vendeur, 2 si Admin, -1 si erreur if (user.type == "Client"): return 0 elif (user.type == "Seller"): @@ -28,22 +41,4 @@ class UserController: elif (user.type == "Admin"): return 2 else: - return -1 - - - def delete(self,entity,database_session): - user_dao.UserDAO(database_session).delete(entity) - - def get_all(self, database_session): - list=user_dao.UserDAO(database_session).get_all() - return list - def update(self, member: User, data: dict, session): - try: - searched_user= user_dao.UserDAO(session).update(member, data) - return searched_user - except: - print("erreur dans la mis a jour de l'utilisateur") - - def add(self, data:dict): - added_user=user_dao.UserDAO(self.database_session).create(data) - return added_user \ No newline at end of file + return -1 \ No newline at end of file diff --git a/main.py b/main.py index 0b7dcac..f8d571c 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,8 @@ from model.dao import advertise_dao from model.dao.advertise_dao import AdvertiseDAO from exceptions import Error -from view.window_view import Window +from view.window_view import WindowView +from view.terminal_view import TerminalView def main(): #Base of the code database_engine = DatabaseEngine(url='sqlite:///my_app.db', verbose=False) @@ -17,7 +18,9 @@ def main(): #Base of the code with database_engine.new_session() as session: - Window(session) + #WindowView(session) + TerminalView(session) + if __name__ == "__main__": main() \ No newline at end of file diff --git a/model/dao/__pycache__/advertise_dao.cpython-39.pyc b/model/dao/__pycache__/advertise_dao.cpython-39.pyc index 1a3056a5ecf77bac1cdf13dfbe3e847f229b3a6f..10a0c3b5b14942e42eabc2984dc53b5fd4345251 100644 GIT binary patch delta 37 rcmcb~c7u&Kk(ZZ?0SFEyg(R)m$h(A*F>dlEMrUS2J;TjE850-*#PkZj delta 38 scmcb?c9V@ak(ZZ?0SH{z1SHMa$h(A*F@EwUMrRhM#NyP=KNu4j0nH-|V*mgE diff --git a/model/dao/__pycache__/user_dao.cpython-39.pyc b/model/dao/__pycache__/user_dao.cpython-39.pyc index dac2cae200fa9ab75ad2e66ab94bb1d9fd4ab163..6d86ee94b6de0dee96c0332c49da5594588761c5 100644 GIT binary patch literal 2872 zcmcguTW=Fb6rS0e*N*Kt0a}{U)&=_DUeeG?s6wcMLV-#&y`&XlWof(dOv0vnF|%ug zt)veGi6{EhM;?;L{0{!bzV@j<pwI1hW^Lm*<+Zl<%$zf~^PS6_2^x(W!*8$uX!8)g zKZ%+BSzxZ=%YFe7Oz?=s+~cv~8Ju_{GGoiLbl;3@&xXv3oVemuw9Jm&xaw7P--&AR zg0~RYy*g*NnWzZ&DHE=&?wejim>aB9{R^kCj!`Ub{BZYr)O#S~;nzx~s%U<b<Z@eu zdC7Np(O6G^l-VH4Z>57otV3e`oJob&ym|dQ>|vKHTbPv&R8Ov_<<uUXG5a&eOs3G0 z%;SQ2#xu6X1sBFs*E5AFtf$Pgge@GjwsfQ;DlZJ-it1C#t7yIkenHg11CeOF;G!uO z!PVpf_!dT`B0I3-SFm&P+@F|P^KXNn4G4y}8}j9%0y)#%GwAUWG-2Yi<wax&)z zJL2mEGaK}!DqP<WlQ8#vh^$OTTV6{9d9WE|($8d;g=uoci>mMUq9DtB|A_s4AA8=o z(xtPr?nW4=N%yAAe$CT<_j4J`_Vpxrc_h2HUmhi)Y~M|{!(J$(?)NI)k@>AK38L<W zORJZ<aVj7dLE0T)D<7TJ{!rDidxKQh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z>c0PQ5JcsOuGDG;8>w?dE)jW;$axUl5n(S^9}%w$$tTn!1&YS_G0~Gz<oh!^Hfah~ zKve}<z^7BhHR_h@xK7J$RhqTdvL5X;y=L|>3d+acs(joltwFKiEzgV~ob)IaV$T{3 zLg6jzm&a-x^!s75y*j|_L+j`@$^m+b;8PBk6g6xu`#Ii0nKrd9=30dr&Gp5qOSyZs UwAPnYnDvF)f{g)z*Nv9>FAC{oaR2}S delta 176 zcmdlXc7Tm9k(ZZ?0SFQo1tfJdF63iml$p%WD9+W+z`_v463n2<Jh_e0oKbV~K1O@S zsLB5ron@R7i&JBA^HWlDVp0<GV@iuti{gO{y@JXj?#VGs3QU@;lOJ%ZnsWn<y~P_J zpPZ9eT%4SmlM^3b#19mM5WFCk0EplO5+Jq3OhAHzX>u)BrvO47m?bb-j9Uo+N~R~( diff --git a/model/dao/advertise_dao.py b/model/dao/advertise_dao.py index c7c0884..60d571f 100644 --- a/model/dao/advertise_dao.py +++ b/model/dao/advertise_dao.py @@ -12,4 +12,6 @@ class AdvertiseDAO(DAO): def __init__(self, database_session): #intialize from mother class - super().__init__(database_session) \ No newline at end of file + super().__init__(database_session) + + \ No newline at end of file diff --git a/model/dao/user_dao.py b/model/dao/user_dao.py index 9fc7685..345941b 100644 --- a/model/dao/user_dao.py +++ b/model/dao/user_dao.py @@ -14,7 +14,7 @@ class UserDAO(DAO): #intialize from mother class super().__init__(database_session) - def get(self, id): + def get_by_id(self, id): try: return self._database_session.query(User).filter_by(id=id).order_by(User.firstname).one() except NoResultFound: @@ -43,7 +43,6 @@ class UserDAO(DAO): def create(self, data: dict): try: - id = str(uuid.uuid4()) member = User(firstname=data.get('firstname'), lastname=data.get('lastname'), email=data.get('email'), phone=data.get('phone'), type=data.get('type')) self._database_session.add(member) self._database_session.commit() @@ -59,6 +58,8 @@ class UserDAO(DAO): member.lastname = data['lastname'] if 'email' in data: member.email = data['email'] + if 'phone' in data: + member.phone = data['phone'] if 'type' in data: member.type = data['type'] try: @@ -71,5 +72,6 @@ class UserDAO(DAO): def delete(self, entity): try: self._database_session.delete(entity) + print("deleted") except SQLAlchemyError as e: raise Error(str(e)) \ No newline at end of file diff --git a/model/mapping/__pycache__/user.cpython-39.pyc b/model/mapping/__pycache__/user.cpython-39.pyc index 4d1a1594a8f39cca464af48efab16e4c52a90e06..1fe9e44da813ca043207237dbde29031ef42c701 100644 GIT binary patch delta 35 pcmeyx@soo)k(ZZ?0SJUA6mH}eWMYh*EX(A~Y^Z0rIfY4#2>_H*2Z{gy delta 36 qcmey#@r#2yk(ZZ?0SLY=3fRak$ix^mS(eF}#VN5kb#pS47!v@rR|!f0 diff --git a/my_app.db b/my_app.db new file mode 100644 index 0000000000000000000000000000000000000000..05b1e6ddfc7257c80b42f44b7e89b7673d991577 GIT binary patch literal 28672 zcmeI(&yL$f90zba$;RDP69cPY<$@f9L?Z1({u_@ENDZrqR)nR^ZYVue(bygftNF8y z-3qQ%g?NYFcmW=OLk~Sx9Js+d@BkbcyW6B2Y1xPq+Wn4Yd+Zr|JfEL)@a*jIy<w7Z zJzgwlEYof2JxP|OTe>buQcbLiSl_0S$W-1Qh`szy{-SJ6>fXOyQ~#E#H(yKjpVZ&f zpKrddAJ;#+=mMOF00bZa0SG_<0uX=z1R$`5z_Ys*MQgR>=Z`WLOgW35@@1B!JYDB@ z4o8Fj$v{8pe?A=O>+^bhZ#RkbZ~CLd+x=17?sfE|uTS)&@o;#c@9kzuHsz~Q*EnB# zx=g}#skKoW@ibf}r&+R?ukK(O8<pZ@nPzh~<CBz6r+m4px!Kl~ZCCH^=+0OD(F6U< z!2`XWM4h}B<D)zG#sj@w^yWa{Z1X_hxOr!<V^^!%7cE&z<`MrseLNMPiWBxETNKBW zwco^A=M{Tr%ZtqQMb&4TtZ14hKd%+Rdy?{HT5L+^LROr*BwDMEU8;Ct1wLcRbX97( z8}GyEcZ>Nt;--84eaL<|T^HILk^Z;9tR8$F3K4@&xvG7pT@-@?WMUP&N~d&rRkNsC z7Qd$(`EM%!$gk92O6m)hs-^l%v3!!BM}hzZAOHafKmY;|fB*y_0D)^M@Zx=~p*4MK zP}`1e5-~d@jum)>hIT+)8phnVJj<tH8mDoTZ_YBu#ejxD`?jez8_k{_QO2B@FgNNE zhkF(YOfMp#8JkYf^Fy1m!y!-RS^78<OR+tiCVZZWd)#lR`wh)9Y$q~YM#8wSDC34m zP3oCe7`Q$$dyYe#{2^%=a1z-;>^qJZ__mqxG<$b_^Jq?48LJ{`%nPY&S`mo@DsI6X zg9Mau68Jq%UFuWQvY1HyXqL=bNg40A{Eo(W&yDQJB%)o9IFav@z>W>#8ez<wkWni% zkCWMuKNTZD^F@+QSGij}>+&?=tQ#+lUe|HD)b3ie>(Qc#P*%oT-UJOI!wk4jsB0O- z>3N*^o@mE3W7`ZIZkbLfnpn*LLnC`awW2<h)Q9RH>W}I#`Eo7aaC9015P$##AOHaf zKmY;|fB*!pk-%u15ss<=>1;EOvC}S(<!uHgl)U0L!w==6;ua$grBBP_-EGDV-hBVR zlGH!dztrE=S7Q0~8U-9(g#ZK~009U<00Izz00bZa0SNqW1U{C}=2GM%4-NTjdc=-6 z_)r$}8ETbABi|Qu8x*CYsxo8c4=VdD`P{^V(tbs2?QTpI$mjoyfBHv)00bZa0SG_< z0uX=z1Rwwb2teQp3*>+Q$M^pg4lud~0SG_<0uX=z1Rwwb2tWV=5D)_R{>N(o0SG_< V0uX=z1Rwwb2tWV=5V-mR{{R}i>B|5B literal 0 HcmV?d00001 diff --git a/view/__pycache__/terminal_view.cpython-39.pyc b/view/__pycache__/terminal_view.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1ad4e33a8a40cbf2c5aa8b358d6db67328733811 GIT binary patch literal 1668 zcmZWp&2Jnv6u0MlH=AuplQsl|MnXUqkw|IUMvAJaQPNaMQIs|XmDNh4>Dnoi%z75v z8^~&UN)H_Q6B?<PaOS|h7sQ#9Pe`1~oin`Woh@7NuKn}-@_YW-<8*quPN01xPoJzu zg#3ZRWOG5d3ter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{M35=+f_kr_JpTN<=IWEG{ zRWI<$pgR6amiYFYrlrA}a5lOISFJJ~Khc&d>4UpXFi`{^kHkt$bZ1oiCOo-B*;g32 HfS>aZqo2WK literal 0 HcmV?d00001 diff --git a/view/__pycache__/user_view.cpython-39.pyc b/view/__pycache__/user_view.cpython-39.pyc index 3b1b719e863565ef2cfc4c1c9158ea88a31aad5d..6708185ba33e18590440f9dbc332124c6bd533df 100644 GIT binary patch literal 3439 zcmai1&2JmW6`$E}eu$=J#kG?*-8g9>rVXRCXby(p#Fdg<47Pxh7+xq?tT`ij?d2{t zyOLpgd9trP^j;Je(2M?#{1<y{Preidie8)m>F>>QX)1BrCFae0^WMz7d0#V(*4Ek# zUq_wX{o5tR{z1g*XM*?`E&n}$V1g%X!UN6;HxgrF2ByZ%#G2TFt#K=HCT`$z_8Akl zaGo;ZJTU@KxO;5iJ;yq1z^mRDxl}t@TBs~Zq{4`IjFC`88E}`lyEp#;)FO0DvsOO? z#K&m)Eda>^E?8g)E{vxvFoh{B^j5ulU<+4xpdHZ?ZS=0_h%S0htcf1_mbf7L=-c8V zG+eJd+VRU+J{;37%||%39kiT`R`QaCumk4s5ftr<sEF=HxeRle=W&(}jLOPoa-dvD zpE1=!_n$8ScCPQ!7Ww{OJjv4iU70^9vg!VB<wW{7)AZ{zx&PVMXK5_`TiIbej%Bj{ zN0r@|#iwx^CHrrGF#KTu1p4hCW0jDw;q+1Eg<+h=MHqV6BG;<(*~R88!-hL{z-~Sg zC0ZZq8W0@HD9zF;ZNdLy&z*vm><NFyOXrl&-I82rjLz(;br7q(NTZ3Yyd+v+wwy$9 zQrXjcSt={5cr=v*Ly;zx8wo+G47|!+m`AOFp?U-^5a<)Q2vD{3xyYPB8}p<HX+Ybr z24sG<4$wi%X(HoB^ZVAZdwkYk9(=L$51dKv(C6L;QgXo`m};v)Sl{O*zi*(KXcn4{ z=AgO4{FCzp!Jm4Nvk24fw@1&v!}sEM?>&yi+<&~Z4e-V|bAR)(HqU(EKh_2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ZTVXVrkmjzlsg;9o<1ZTw3TN=v)Z{Nq6Atd z(Fq7#haACg()EenLQ<JXs)O0E;LnVeu(b<Qhp~NXa0VWQFs|2AydrP2bYl^~PJOxF zVX3jj3WpL8mu?rBzJ7(dR~H#~G`n&xV1-O%A?uLcScdG%s19|dYuT^=Pe?3gtp<gw zeucy8$WRmlij1Is22izYaWcFP5d@H~YxMS0IwIDW-bM`UYDI%y6B9M9-Xm#xn5?{W zsK$MXmeZv|z9dhQ$GY&J!+S;>wS9JpcGlJWr6T99Nvg)wcF=OF@>Hzxn5!*9dk%Q5 z^7;L7vN&H<(wOE_onYrST=GYQ4n0G4fe)*87)~;AoX9Y&x?y;993?eJ(X&mz-?Z)2 zH6njOU`T)tthNZe)I?+Y+1JFLe)b`xO|Rv3yuRmpzIRDGWHe|6uS4U-UyI=}EJIhx zg03H=EvP1wA^vVC6I)g5OS+aP23e_LOrq&DP7gIx(ZyK%{uLTl-gbTL8)WXBqM!?3 H;b;68QC%cf delta 279 zcmaDa^@W8mk(ZZ?0SH#D4oG^(Fp*D&(QKl&x`;bN3QG!W3quNPGgA~>3R^IPCi}!9 zJ*#ApT4cZk<TwCvu?UbzWr$)-VTfW%VN79aVTfW*VFv1Bxy2G%oLV$lj?sgc4X9`( zLlFm%`WiO5n9-TVDX}<p@=it>S$2>iAk!Eat9U^g^y1?)^D;}~<NY*QCI|7T8i3ph z)`~=Mg2Y&X1PFt*b1;GVewyr)Z}4~-fjLMTKvoxlblu{x$<0qG%}KRm1Zf4ijE4~j FnE=NnFt-2z diff --git a/view/__pycache__/window_view.cpython-39.pyc b/view/__pycache__/window_view.cpython-39.pyc index d6f2c20f0dc1a0fd8fa8de27848dc39fa1a616d5..e938d3e02520fd9bbfc325207899954e57e2ba02 100644 GIT binary patch delta 349 zcmbQmx|EGKk(ZZ?0SL6Z3zM!-<W1t_2rW)63d>9_pIG9g#uc8Kmy%x&;wCeJltBTA z%?`xQKwRuI@rHVR32O~Q7DF@R0=5*U6y_9`6xI~Bg{+JWC9DhBK{5*&85vR-f*CZ~ z{h~MwjVuf*%#949Sc5Zj^Yfy(d{WCY^YilZGmERla^P%-)Dpea;>^@Uy|kh#J_9p7 z6B9iPV?84aJ#&j&44NFb*o#w(i-8)Wm?q0I${7|h1DzAao|uvX@<SANdTI%X;geZh zqRDiNr8qSwtqA1ml?+9kK<aDw<UmGeW<x#0$uk(0rFnot42*1y9E?27Tuc&-Rl;!3 ePd>+JB+3nx2J1s2xF(A-MGAlnLlLZFk^ul1J5#a% delta 199 zcmZ3=Hj9-vk(ZZ?0SH#E4M@_P$eYB<5?Y*EG_k@-i7h-cFD1V`nF%Bf1t2yv5IX~L zvBty)>cS}u!3>&Aeo-8TMivGY=0*mZtdpx5HN`ZUZm|@n=A;#|0hO*~DB=K8Un3@8 zWprk7N-R#DEX|}W3=(5tWMkxD<YBJj2U|BelF3LE<RGvHB!YAD0;Wg-kPZ|<PG%VZ D?q(&~ diff --git a/view/terminal_view.py b/view/terminal_view.py new file mode 100644 index 0000000..f319819 --- /dev/null +++ b/view/terminal_view.py @@ -0,0 +1,52 @@ +from tkinter import * +from controller.user_controller import UserController +from view.user_view import UserView +from view.advertise_view import Advertise + +class TerminalView(): + def __init__(self, session): + self.session = session + self.user_connected = -1 + + #UserView.deleteUser(self, self.session, 1) + + print("---> Terminal View <---") + print("1 -> Add User") + print("2 -> Print Users list") + print("3 -> Connect") + print("4 -> Edit user") + print("5 -> Delete a user") + print("6 -> Disconnect") + print("7 -> Informations about connected user") + print("Q -> Exit") + entry = input() + + if (entry == "1"): + firstname = input("Firstname : ") + lastname = input("Lastname : ") + email = input("Email : ") + phone = input("Phone (XX.XX.XX.XX.XX) :") + type = input("Seller (s) or Client (c): ") + if (type == "s"): + UserView.addUser(self.session, firstname,lastname,email,phone,"Seller") + elif (type == "c"): + UserView.addUser(self.session, firstname,lastname,email,phone,"Client") + elif (entry == "2"): + UserView.getUserList(self.session) + elif (entry == "3"): + firstname = input("Firstname : ") + email = input("Email : ") + self.user_connected = UserView.connect(self, self.session, firstname, email) + elif (entry == "4"): + UserView.getUserList(self.session) + UserView.editUser(self, self.session, self.user_connected) + UserView.getUserList(self.session) + elif (entry == "5"): + UserView.getUserList(self.session) + UserView.deleteUser(self, self.session, self.user_connected) + elif (entry == "6"): + self.user_connected = UserView.disconnect(self) + elif (entry == "7"): + UserView.printUser(self.session, self.user_connected) + elif (entry == "Q"): + exit() \ No newline at end of file diff --git a/view/user_view.py b/view/user_view.py index ae6a71a..eba80d4 100644 --- a/view/user_view.py +++ b/view/user_view.py @@ -1,8 +1,106 @@ from controller.user_controller import UserController from model.dao import user_dao from model.dao.user_dao import UserDAO +from model.mapping.user import User -class User: +class UserView: def __init__(self,database_session): - self.database_session = database_session \ No newline at end of file + self.database_session = database_session + + def addUser(session, firstname, lastname, email, phone, type): + user_data = {"firstname": firstname, + "lastname": lastname, + "email": email, + "phone": phone, + "type": type} + added_user=UserController(session).addUser(user_data) + return added_user + + def printUser(session, user): + if (user != -1): + print("-{id} {firstname} {lastname} ({email}) {phone} {type}".format(id=user.id, + firstname=user.firstname, + lastname=user.lastname, + email=user.email, + phone=user.phone, + type=user.type)) + else: + print("User not connected") + + def getUserList(session): + users_list = UserController.getAllUsers(session, session) + users_listDict = [user.to_dict() for user in users_list] + + ###Test to print in terminal### + for user in users_listDict: + print("-{id} {firstname} {lastname} ({email}) {phone} {type}".format(id=user['id'], + firstname=user['firstname'], + lastname=user['lastname'], + email=user['email'], + phone=user['phone'], + type=user['type'])) + + + return users_listDict + + def connect(self, session, firstname, email): + try: + user_connected = UserController.getUser_by_name_and_mail(self, firstname, email, session) + return user_connected + except: + return 0 + + def editUser(self, session, user_connected): + if (user_connected != -1): + if (UserController.User_Type(self, user_connected) == 2): + firstname_toEdit = input("Firstname to edit ? : ") + email_toEdit = input("email to edit ? : ") + + new_firstname = input("New firstname :") + new_lastname = input("New lastname :") + new_email = input("New email :") + new_phone = input("New phone :") + new_type = input("Client (c) / Seller (s) / Admin (a) : ") + if (new_type == "c"): + user_data = {"firstname": new_firstname, "lastname": new_lastname, "email": new_email,"phone":new_phone ,"type": "Client"} + elif (new_type == "s"): + user_data = {"firstname": new_firstname, "lastname": new_lastname, "email": new_email,"phone":new_phone ,"type": "Seller"} + elif (new_type == "a"): + user_data = {"firstname": new_firstname, "lastname": new_lastname, "email": new_email, "phone":new_phone ,"type": "Admin"} + else: + print("Not a valid choice") + + try: + member = UserController.getUser_by_name_and_mail(self, firstname_toEdit, email_toEdit, session) + UserController.updateUser(self, member, user_data, session) + except: + print("User not found") + else: + print("You do not have priviledges to edit a user") + return -1 + else: + print("User not connected") + return -1 + + def deleteUser(self, database_session, user_connected): + firstname_toDelete = input("Firstname to delete ? : ") + email_toDelete = input("email to delete ? : ") + if (user_connected != -1): + if (UserController.User_Type(self, user_connected) == 2): + try : + member = UserController.getUser_by_name_and_mail(self, firstname_toDelete, email_toDelete, database_session) + UserView.printUser(self, member) + UserController.deleteUser(self,member,database_session) + except: + print("User not found") + else: + print("You do not have priviledges to delete a user") + return -1 + else: + print("User not connected") + return -1 + + + def disconnect(self): + return -1 \ No newline at end of file diff --git a/view/window_view.py b/view/window_view.py index cd3ca37..50e1612 100644 --- a/view/window_view.py +++ b/view/window_view.py @@ -1,13 +1,16 @@ from tkinter import * -from view.user_view import User +from view.user_view import UserView from view.advertise_view import Advertise -class Window(): +class WindowView(): def __init__(self, session): self.session = session self.window = Tk() self.window.geometry("1280x720") - self.window.mainloop() \ No newline at end of file + self.window.mainloop() + + UserView(self.session).addUser("Simon","Levionnois","levionnois@et.esiea.fr","06.44.83.28.78","") + UserView.getUserList(self.session) \ No newline at end of file -- GitLab From 91b888f098c38391e29639a0d5fea0024faab4fb Mon Sep 17 00:00:00 2001 From: Simon <levionnois@et.esiea.fr> Date: Mon, 9 May 2022 19:29:46 +0200 Subject: [PATCH 3/4] Connexion + Register + Visuel Fonctionnel sauf le visuel qui n'est pas ouf --- main.py | 8 +- my_app.db | Bin 28672 -> 28672 bytes view/__pycache__/user_view.cpython-39.pyc | Bin 3439 -> 3451 bytes view/__pycache__/window_view.cpython-39.pyc | Bin 805 -> 3873 bytes view/window_view.py | 88 +++++++++++++++++++- 5 files changed, 89 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index f8d571c..cff98dc 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,8 @@ from exceptions import Error from view.window_view import WindowView from view.terminal_view import TerminalView +from view.user_view import UserView + def main(): #Base of the code database_engine = DatabaseEngine(url='sqlite:///my_app.db', verbose=False) database_engine.create_database() @@ -17,9 +19,9 @@ def main(): #Base of the code # Permit to attribute the "Session" class to the new session with database_engine.new_session() as session: - - #WindowView(session) - TerminalView(session) + UserView.getUserList(session) + WindowView(session) + #TerminalView(session) if __name__ == "__main__": diff --git a/my_app.db b/my_app.db index 05b1e6ddfc7257c80b42f44b7e89b7673d991577..f3c88b312b14b1dd59391bd0fc88b8ef913be628 100644 GIT binary patch delta 381 zcmZp8z}WDBae_1>|3n#QM*fWnOZWxY_+%LPXY*U|Gx6=`OXHK-tf;`jSMR~e9x5s- zsw|moXl80+X<(|GmS$wCYm#DUrfX@CW~!THm|~flY@BEb#38B0B_&W?m{M2_Mb0^y zsd**g9PFXelB$~G29}m-hK7m8y2eH+Cb}l6sTR7HDds?v(kzlw4Gj&FjFMA)@{3aQ zs`7nQQqxk)QghNA(sL6tbM%t)bInZkjDW}xgbYm_Q*tx&Ht&~nWfWlJ=VstH;g99N z!QaNeo}YWOqQQ5*APweFMq-@K2~tRm%Qz;->MsXcwupg$1OH9_H~fqEFY+JWEa=e3 eugJ?HD#{281Wq9qX-P(yN5KBz*nHUD)&Kx%G;0I^ delta 365 zcmZp8z}WDBae_1>??f4AM&6AHOZWv?`1UjK&*rz_XX4urgesdA6@>ZfXA6ppic4Br z7+4q^ry1*}BpN5{niwUS>sllmC+V76B&Ves8<`tfS|k^z6{n?u2q+^sH76&vh=GA2 zLXuxnRMN~i#Ue4$BuzKbG{sEUB-PwVH_6aEMK{?n&Cn#t%re>7BGK6=H8ZcIxG)6> z!KAZfPG)Le3DA&mQGQ`jaU%m`lN1BfMBU`H&HLqC83kDQV;T5k`ET&I@vjHL&58!U z`22&2aW5OtR83-B#X31we>u>m!wmd4`QPwg<Ub6AyEh9uOyHMSVubn@WSS@=)B~(Q Pju>M}YVqd7_O=E9*7as1 diff --git a/view/__pycache__/user_view.cpython-39.pyc b/view/__pycache__/user_view.cpython-39.pyc index 6708185ba33e18590440f9dbc332124c6bd533df..e14e7ef1827d4ffb171c5a5f647c7e4f1ce51c14 100644 GIT binary patch delta 329 zcmaDa^;?QJk(ZZ?0SK<VuSi<BkvE0W;Fp85RZM7cYEf}aaAt0PUW`kAa%paAUP*C` zduEA8X;O@HekoAWIk6}{I3vGc^G?QecE($q6*-j|>wADkl`y0*HZ#^T18F88%~HdZ z!ko=qR8zvZfT@O|hG`*F3QIOqQC^iEP=pyM!d$~r!?=*8mbHXs0V|Ntx{!&H0Vu}? zVgqHE85zPE3ac0yK(K^8g|(THks%T&V!%+?0pzoR_$kc640*ylKrTCso5B#xpvf`$ z0GBzV+T_n%HoP1~IzaaoF@Xr}$>!XVjCzwNato^)00qK;xL5{AFfej}p#UQjqW~ih lqYxt-qW}{JBOBA?<J>2?^?@piKpKh+C)@IhPu|3{7XTJ!Pk{gc delta 308 zcmew@^<IiMk(ZZ?0SLH@%956B<V|7p_!<i2I$Onr7N-^!#{_5Q=I6z@q!wqF<QK#k zr{<<AIOgRYUYQ!>et2bGW~zcuetKqdW@=7MKv8~HYKdEBUSdv+vZ0>g=7o&u?2J*H zIXRUX8OtW?a!DnoRq2&5E?}x*s9~;QsbO5mQp;MxynqGBXI;p|$N-dM1+jrL%!~}- z40$4q3?Nv-mcr7^$jA`MkjG>I;<18wc|1TC8;F&{9L$iy5X_*-K6xLP`Q%?*798wF z+CX0vF-^ATjx^T=F*)G`$iGGUKq3r?izR>r10x3rGBGg<F!C@8F|sl8F>x_ZzRZ1+ QTMsA;R$OE-c{$G&0L<t}iU0rr diff --git a/view/__pycache__/window_view.cpython-39.pyc b/view/__pycache__/window_view.cpython-39.pyc index e938d3e02520fd9bbfc325207899954e57e2ba02..4dd43e2c3f00b4dac2a29528c49e7846df8ee472 100644 GIT binary patch literal 3873 zcmb7HTW{RP73T21H+gl5r8udxZc`^rTUBk-v{elwvErmf6(NXHJ0OHCs2yrWi%Y6Q zu4OG&Kmi-5U)0|qKdL{8uj$J^w@-fRcV?Emt4oV!r8#rqnHkPG-*@IPXf&!Ce*gT_ z@$PC<)4rq5?9V{wW0dSZ1lKr=wXdnxW7gAsol)C}jh^Y7vTepz&-QJmeXenf+b=Y3 zKi7SSJKLJ)j<AO2v4VX7VH^e=mHX!`6py0t2<^%z{AnoiC<{BJIs4Pm`4}a;2N7yM z<C?E?#`PDPZ*YT~s7<w_Z*hma=-a%)tEe4b<8{<7Z{RKFit6Ji;pq`=+M#vJAGPVc z8z|Wt#E=cOwwAN!8fty0J<-n$&R#Kw{+anoqZ(rtwYY}0^)281#oF51vyax+JiBnR zFw3Ge@%66{3j0Xz>bu=A?S;8GF3c~&r0=`EAWGsiJ@oX#%))q2IN17J6E#$?A8f4e zkcG0H?WmU~JD;YVelJY&Z0GYR|3iOwXCv+7;YJ|Z+xzL^&Qly}NA1+6_Uhqr;kMgR z66Ni7g$^eD&1~kfy6)<O#i=n?OT7+*V)--Ca8bxI*<T@Y?WOjFk?qOur{)P8vL`y( z9)HfM!L-~UjlXGojJv$@!sS(7J2g)9p$@$|v<%+JO+I&OUC_NDb(>Px7#h%J(4CjM z246S@s-%?{w?^cu!OG(>?!cC<JZ-@Wtt{Qkj{*^{j+XHF-0<!FFzW8-g_(!XAotQF z7j(3d1>qTmA=0D5?xb<Qm-tmxXNN&@E&3KQCnH0=)Xub5@b)>|BFx5VH%iEp(qZRJ zkbz}e)X^&3dvVa)<-z?o(EAsPHn=lmbDFt&FHSo_oZUx5=@!+EG)clv4)mPsg@a@E zf`p5COdrt^qJKkrmY|agTDh<y5b9ZBN@-_#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qb8`UL7AGIBo`AxK^Q@wMXWiN9boxaR7qj&oGl^GhHM4yZNT9=<p7AMi$PS}a= zu(i>mEJ--Ld8h&@O=e0d=|a1K2AIzRw&67S8#dYgKa_A8Ily7zu`EutlvPv8G*{z< z@P?GP<2YID6ziC)Ca_}YZ5AFHAJx)m16KQkmR~i>k;zKz$W~q582Q$9F8Z}ye~g!J fY_a1m^R3)LJuB#<DtNyr?F0S@VChOEhSdH7-)6>o diff --git a/view/window_view.py b/view/window_view.py index 50e1612..a12b099 100644 --- a/view/window_view.py +++ b/view/window_view.py @@ -1,4 +1,6 @@ from tkinter import * + +from numpy import pad from view.user_view import UserView from view.advertise_view import Advertise @@ -7,10 +9,88 @@ class WindowView(): def __init__(self, session): self.session = session self.window = Tk() - self.window.geometry("1280x720") - + self.window.geometry("1000x600") + + self.Menu() self.window.mainloop() - UserView(self.session).addUser("Simon","Levionnois","levionnois@et.esiea.fr","06.44.83.28.78","") - UserView.getUserList(self.session) \ No newline at end of file + def Menu(self): + label = Label(self.window, height=2, text="Welcome to our software.", font=20) + label.grid(row=0,column=5, columnspan=5) + connBtn = Button(self.window, command = lambda : self.loginMenu(), text="Connection") + connBtn.grid(row=1,column=5, ipadx=20,padx=500,sticky=N) + signBtn = Button(self.window, command = lambda : self.registerMenu(), text="Register") + signBtn.grid(row=2,column=5, ipadx=30,padx=500,sticky=N, pady=20) + + + + def loginMenu(self): #Menu n°1 + labelEmail = Label(self.window, height=2, text="Email :", font=12) + labelEmail.grid(row=3, column=5) + + self.inputEmailLog = Entry(self.window, width=50) + self.inputEmailLog.grid(row=4, column=5) + + labelFirstname = Label(self.window, height=2, text="Firstname :", font=12) + labelFirstname.grid(row = 6, column=5) + + self.inputFirstnameLog = Entry(self.window, width = 30) + self.inputFirstnameLog.grid(row = 7, column=5) + + connectionButton = Button(self.window, command = lambda : self.connect(), text="Connection") + connectionButton.grid(row = 9, column = 5) + + def registerMenu(self): #Menu n°2 + labelFirstname = Label(self.window, height=2, text="Firstname :", font=12) + labelFirstname.grid(row = 3, column=5) + + self.inputFirstnameReg = Entry(self.window, width=30) + self.inputFirstnameReg.grid(row = 4, column=5, pady = 2) + + labelLastname = Label(self.window, height=2, text="Lastname :", font=12) + labelLastname.grid(row = 5, column=5) + + self.inputLastnameReg = Entry(self.window, width=30) + self.inputLastnameReg.grid(row = 6, column=5, pady = 2) + + labelEmailReg = Label(self.window, height=2, text="Email :", font=12) + labelEmailReg.grid(row=7, column=5) + + self.inputEmailReg = Entry(self.window, width=50) + self.inputEmailReg.grid(row=8, column=5) + + labelPhoneReg = Label(self.window, height=2, text="Phone : (XX.XX.XX.XX.XX)", font=12) + labelPhoneReg.grid(row=9, column=5) + + self.inputPhoneReg = Entry(self.window, width = 30) + self.inputPhoneReg.grid(row=10, column=5) + + self.radioValue = StringVar() + + radioClient = Radiobutton(self.window, text="Client :", variable=self.radioValue, value="Client", font=12) + radioClient.grid(row=11, column=4) + + radioSeller = Radiobutton(self.window, text="Seller :", variable=self.radioValue, value="Seller", font=12) + radioSeller.grid(row=11, column=6) + + radioClient.select() + radioSeller.deselect() + + connectionButton = Button(self.window, command = lambda : self.register(), text="Register") + connectionButton.grid(row = 12, column = 5) + + def connect(self): + user = 0 + user = UserView.connect(self, self.session, self.inputFirstnameLog.get(), self.inputEmailLog.get()) + + if (user == 0): + labelError = Label(self.window, height=2, text="Wrong email or firstname !", font=12) + labelError.grid(row = 10, column=5) + else: + labelConnected = Label(self.window, height=2, text="Welcome back "+user.firstname+" "+user.lastname+" !", font=12) + labelConnected.grid(row = 10, column=5) + + def register(self): + user = UserView.addUser(self.session, self.inputFirstnameReg.get(), self.inputLastnameReg.get(), self.inputEmailReg.get(), self.inputPhoneReg.get(),self.radioValue.get()) + \ No newline at end of file -- GitLab From ab798d281ea392e79c3b1d026edd1998fbf8fff1 Mon Sep 17 00:00:00 2001 From: Simon <levionnois@et.esiea.fr> Date: Wed, 11 May 2022 14:29:03 +0200 Subject: [PATCH 4/4] Actualisation Actualisation --- my_app.db | Bin 28672 -> 28672 bytes view/__pycache__/window_view.cpython-39.pyc | Bin 3873 -> 3965 bytes view/window_view.py | 45 ++++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/my_app.db b/my_app.db index f3c88b312b14b1dd59391bd0fc88b8ef913be628..407a282d7dd793537f8cece1588d0989dd2397eb 100644 GIT binary patch delta 366 zcmZp8z}WDBae_3X;6xc`M!}5<OZY`Nc$*pcXY*U|Gx6=`OXHK_-NxIzSy3RHx89JO zJ(L#+B$JKJO$^N}Qgtm&QY~~%%q<OdEmI6rbd!zEl1<DL4bqZRQ-f1;a#D*@xY$Ew zWz97ujV%q$EsRnUb&XPtEp<%{EK_xp%uS4SEezAllYoY$q$Z`fmuBYVWG3bXB$k#W zW)`I;=Hw*irj+Jn<|I0#=O#*J=IABo=Ng&n8JXxA8S5Dt=@}V9tl2Ch_kvM`gKsAT zzX{(X{#gDS{B8W}`MLRaZdO!S$QPu+9Lh+Hqq#u}iE%2|WN!VR931>@3_y!|HggzM a@yoEX@bWTpi?YbdGNSv0Yx5%eI0FDBA!DQf delta 90 zcmV-g0Hyzc-~oW(0gxL350M;00S~cYqz@1V4jcdvn-4e-0uH|pW)2*)As`42vm74i w0T2cc3jhx^4_yz~4~7q~4-2y)F!v6V3orQu1`nbDvkWkL50Q`{v!Xv<FeFYGX8-^I diff --git a/view/__pycache__/window_view.cpython-39.pyc b/view/__pycache__/window_view.cpython-39.pyc index 4dd43e2c3f00b4dac2a29528c49e7846df8ee472..8c8ccd8c62526dd98a84aca16dc88e4fdbdea59e 100644 GIT binary patch delta 1449 zcmZ`(OKVd>6uxucuf&)>lGG+`tlD0!sqt;C?>E-ss|YTHG;=MjHIcbj)RIyKK@qZX zcDiz-=uYq-xKP|FC~`Nt%`b2zc+TX}3L2R2o;l}a&g+|bk^7yCmtrwnf?s)gapvgS zxABvN6!|pyVq2h8U<D6(QO+$J)T}E+3YEvwJb5HtC)A?$Lz6nxtt(4%O`ex&jOtXO z@ld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/view/window_view.py @@ -9,7 +9,7 @@ class WindowView(): def __init__(self, session): self.session = session self.window = Tk() - self.window.geometry("1000x600") + self.window.geometry("1100x600") self.Menu() @@ -17,68 +17,69 @@ class WindowView(): def Menu(self): label = Label(self.window, height=2, text="Welcome to our software.", font=20) - label.grid(row=0,column=5, columnspan=5) + label.grid(row=0,column=5, columnspan=3) connBtn = Button(self.window, command = lambda : self.loginMenu(), text="Connection") - connBtn.grid(row=1,column=5, ipadx=20,padx=500,sticky=N) + connBtn.grid(row=1,column=5, ipadx=20,padx=500,sticky=N, columnspan=3) signBtn = Button(self.window, command = lambda : self.registerMenu(), text="Register") - signBtn.grid(row=2,column=5, ipadx=30,padx=500,sticky=N, pady=20) + signBtn.grid(row=2,column=5, ipadx=30,padx=500,sticky=N, pady=20, columnspan=3) def loginMenu(self): #Menu n°1 labelEmail = Label(self.window, height=2, text="Email :", font=12) - labelEmail.grid(row=3, column=5) + labelEmail.grid(row=3, column=5, columnspan=3) self.inputEmailLog = Entry(self.window, width=50) - self.inputEmailLog.grid(row=4, column=5) + self.inputEmailLog.grid(row=4, column=5, columnspan=3) labelFirstname = Label(self.window, height=2, text="Firstname :", font=12) - labelFirstname.grid(row = 6, column=5) + labelFirstname.grid(row = 6, column=5, columnspan=3) self.inputFirstnameLog = Entry(self.window, width = 30) - self.inputFirstnameLog.grid(row = 7, column=5) + self.inputFirstnameLog.grid(row = 7, column=5,columnspan=3) connectionButton = Button(self.window, command = lambda : self.connect(), text="Connection") - connectionButton.grid(row = 9, column = 5) + connectionButton.grid(row = 9, column = 5,columnspan=3) def registerMenu(self): #Menu n°2 + self.loginMenu. labelFirstname = Label(self.window, height=2, text="Firstname :", font=12) - labelFirstname.grid(row = 3, column=5) + labelFirstname.grid(row = 3, column=5,columnspan=3) self.inputFirstnameReg = Entry(self.window, width=30) - self.inputFirstnameReg.grid(row = 4, column=5, pady = 2) + self.inputFirstnameReg.grid(row = 4, column=5, pady = 2,columnspan=3) labelLastname = Label(self.window, height=2, text="Lastname :", font=12) - labelLastname.grid(row = 5, column=5) + labelLastname.grid(row = 5, column=5,columnspan=3) self.inputLastnameReg = Entry(self.window, width=30) - self.inputLastnameReg.grid(row = 6, column=5, pady = 2) + self.inputLastnameReg.grid(row = 6, column=5, pady = 2,columnspan=3) labelEmailReg = Label(self.window, height=2, text="Email :", font=12) - labelEmailReg.grid(row=7, column=5) + labelEmailReg.grid(row=7, column=5,columnspan=3) self.inputEmailReg = Entry(self.window, width=50) - self.inputEmailReg.grid(row=8, column=5) + self.inputEmailReg.grid(row=8, column=5,columnspan=3) labelPhoneReg = Label(self.window, height=2, text="Phone : (XX.XX.XX.XX.XX)", font=12) - labelPhoneReg.grid(row=9, column=5) + labelPhoneReg.grid(row=9, column=5,columnspan=3) self.inputPhoneReg = Entry(self.window, width = 30) - self.inputPhoneReg.grid(row=10, column=5) + self.inputPhoneReg.grid(row=10, column=5,columnspan=3) self.radioValue = StringVar() radioClient = Radiobutton(self.window, text="Client :", variable=self.radioValue, value="Client", font=12) - radioClient.grid(row=11, column=4) + radioClient.grid(row=11, column=5, columnspan=1,padx=200) radioSeller = Radiobutton(self.window, text="Seller :", variable=self.radioValue, value="Seller", font=12) - radioSeller.grid(row=11, column=6) + radioSeller.grid(row=11, column=6, columnspan=1) radioClient.select() radioSeller.deselect() connectionButton = Button(self.window, command = lambda : self.register(), text="Register") - connectionButton.grid(row = 12, column = 5) + connectionButton.grid(row = 12, column = 5,columnspan=3) def connect(self): user = 0 @@ -86,10 +87,10 @@ class WindowView(): if (user == 0): labelError = Label(self.window, height=2, text="Wrong email or firstname !", font=12) - labelError.grid(row = 10, column=5) + labelError.grid(row = 10, column=5,columnspan=3) else: labelConnected = Label(self.window, height=2, text="Welcome back "+user.firstname+" "+user.lastname+" !", font=12) - labelConnected.grid(row = 10, column=5) + labelConnected.grid(row = 10, column=5,columnspan=3) def register(self): user = UserView.addUser(self.session, self.inputFirstnameReg.get(), self.inputLastnameReg.get(), self.inputEmailReg.get(), self.inputPhoneReg.get(),self.radioValue.get()) -- GitLab