From a3bb7bb674c92d58fcbe361fbfda04663b49008b Mon Sep 17 00:00:00 2001 From: Welton Moura Date: Thu, 12 Dec 2024 21:33:04 -0300 Subject: [PATCH] create comanda | detalhe comanda --- .../__pycache__/models.cpython-310.pyc | Bin 1259 -> 1559 bytes .../comandas/__pycache__/urls.cpython-310.pyc | Bin 345 -> 397 bytes .../__pycache__/views.cpython-310.pyc | Bin 697 -> 1342 bytes gestaoRaul/comandas/models.py | 6 +- gestaoRaul/comandas/templates/comandas.html | 34 ++++++++- .../comandas/templates/viewcomanda.html | 63 +++++++++++++++-- gestaoRaul/comandas/urls.py | 1 + gestaoRaul/comandas/views.py | 30 +++++++- gestaoRaul/db.sqlite3 | Bin 188416 -> 188416 bytes .../mesas/__pycache__/admin.cpython-310.pyc | Bin 571 -> 610 bytes gestaoRaul/mesas/admin.py | 3 +- .../static/comandas/css/comandas.css | 61 ++++++++++++++-- .../static/comandas/css/viewcomanda.css | 66 +++++++++++++++++- .../templates/static/comandas/js/comandas.js | 21 ++++++ .../static/comandas/js/viewcomanda.js | 20 ++++++ 15 files changed, 284 insertions(+), 21 deletions(-) create mode 100644 gestaoRaul/templates/static/comandas/js/viewcomanda.js diff --git a/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc index 092504485513b2cec3cb8376ff5d74e5bca11771..a77ea7a662cbd560c2175f8a3af6a6852572a628 100644 GIT binary patch delta 640 zcmZXR%Syvg5QZ~JXsvByjkWb|#cLM|Zd`~ftJ@-qAX*49=Tt3iQYMK)5d?8Bl7-J8 zzJV{`BM5l_H?G~dawc^ldSJdY%;jYM$w%ffXL$MiphD;9{N(Ije=y$Q_TfD=WwEJ> ztjOKz$D<;Dpj3^>g0LBpiWqTB&Mr+UZZh#zZ~U?UtP%~ K<>*zPhwL|;jC~0J delta 344 zcmbQv^O}<{pO=@50SLUNho}E!p2&Bdv1IZbX06ErjNUB444T}Na~VsS{WL`;_c5)u zxW$r}n47wip-2v>15EsKa<+;IElw>ejww&gDans<$xklLP0cGQj!91~E=kOfFG?)U zne4$NCtJi0)WiwI#R5QrgMo)pfKiB%hmns_gi&B}HM0U^2+-zGkgXh(nOV&0{WJxN zgg_Pvg9s52!2}{iL4+8H5C;(;V~Zq!L=<~+er{r3N@9@|h{u_dSdtiDl9`)Y!~*2s zVlODlPbp0n4G~{ TCJI!56bw+ElRvX6Gjaj|an?x? diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc index a79bde7eaed2bf1957ae592375df203f1cf392dd..9fa1582e1b7570c072d1ee9b493ff101dda23648 100644 GIT binary patch delta 165 zcmcb~)XS`$&&$ij00co*(dpcb3=EG!9Av-_O6wXxUEVdM`6t-UG zbml1b6z*UKO`eH4UP@Jb$wjG&C8^H&xruoxiTbyAQTTqE920lyNf&Vd4ZFo%T9i|e mSW=Q&lvlixp@VE=ub%)9kj2Bu!^p?X$H>RX@fQFOTqXVh delta 114 zcmeBWzR9GW&&$ij00K{<(hmcv$6yW;!3JbI0CBO+L~V1fbfze_6wY7=U2qiQVEZEy^iKEGbDX$}3*UPy{lth->6@YQYwbsxn{5+^uctN-n3iJ*U)(SIXp5ikI7mgAQShV3~U$ESb|2 zc1l*%@^;6psG)=Q?Ys&%>$L9tYl#s`yfd*)Zi>l9aD9t#Y z7lp=b8sSN~i?sT>RL1HEjWLKbq7zVmAB`SP-WjFMHz)2FSEkJTts`#2)JNR&!(!uJ<>gNyn>G1HruC}^qKTk{Im`tYwp_0 z6Vix2Ug=?xqlSAd&Y(zWOxNHQUT-jc1B{pO#s+bDym2lhfjOdMA33E>P00O)RNY+4 zc8G7m7lUIXsJ;p6Qf%xQL;Bb+Ve=oC4YTZ&N`9SO;#D-f!fbOH{A4Rpi<9sa3bm08 zk0?|ajSrIruy(&i>ab^20polhXWY}K*B~Rzzd$!9yd5Vijh)zf{pPLSfP=ngf5{QzyWd*GkpgP<1}#t zInNh6)zIu#+D@0&_$lyNvny>=W>{8I6{eXZgfmP0KYVWYh5Nr0iS-Ql1Q!bP-1!NK ZA49Zdp`IY$2GJRi0fVwc9LGr#{{#I}B@_Sv literal 697 zcmY+C&2H2%5XU`szPjBl;o3LIWra8bLWofHwuc2SQKTx3t!<(tF1ABOl|7X!@6aB3 zAr8KBK)eDc#z|VWmOS>@p83uEWw}}{2#()>vfVGh)j5v`Mduw({Q?aq92(L>1})7f zIG;AG^)e6ljCnFi=i^z@8Z& z8%9|NHaF~VvV+S)6|FEzqJp&I*Rd;Nu4ob=oV_Hl?DXW5WjkRkt2#4Eq5@=3N_Z-A z`$IH#F$bMhTrJ(H6J;{)gV;ldNhh(7@IbrJB}8xpF;&me*(9Njd0linxz-m_nX)%} t1Sy8s*|V9T*RABD(Ni@}k}>=da72&P=ncN@8}ZhCkr5e_C5^mg_#d^Cp9BB^ diff --git a/gestaoRaul/comandas/models.py b/gestaoRaul/comandas/models.py index 2235073..0e3672b 100644 --- a/gestaoRaul/comandas/models.py +++ b/gestaoRaul/comandas/models.py @@ -14,10 +14,14 @@ class Comanda(models.Model): dt_close = models.DateTimeField(null=True, blank=True) client = models.ForeignKey(Client, on_delete=models.SET_NULL, null=True, blank=True) name = models.CharField(max_length=255) + def __str__(self) -> str: + return self.name class ProductComanda(models.Model): id = models.AutoField(primary_key=True) comanda = models.ForeignKey(Comanda, on_delete=models.CASCADE) data_time = models.DateTimeField(auto_now_add=True) product = models.ForeignKey(Product, on_delete=models.CASCADE) - applicant = models.CharField(max_length=255, null=True, blank=True) \ No newline at end of file + applicant = models.CharField(max_length=255, null=True, blank=True) + def __str__(self) -> str: + return self.comanda.name + " - " + self.product.name \ No newline at end of file diff --git a/gestaoRaul/comandas/templates/comandas.html b/gestaoRaul/comandas/templates/comandas.html index 7abc4b3..1bfd0ef 100644 --- a/gestaoRaul/comandas/templates/comandas.html +++ b/gestaoRaul/comandas/templates/comandas.html @@ -11,12 +11,15 @@ Comandas{% endblock %} {% endblock %} {% block 'body' %} -body> -
+ +
+ {% for comanda in comandas %} - + + + diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index e202a90..f4fed07 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -5,22 +5,73 @@ {% block 'title' %} -Comandas{% endblock %} +Detalhes {{comanda.name}} +{% endblock %} + + + + {% block 'head' %} {% endblock %} + + {% block 'body' %} -body> +
-

{{comanda.id}}

-

{{comanda.name}}

-

{{comanda.mesa}}

-

{{comanda.dt_open}}

+ + +

{{comanda.name}}

+

{{comanda.mesa}}

+

{{comanda.dt_open}}

+ + + + + + + {% for item in consumo%} + + + + + + + + + {% endfor %} + + + + + +
ProdutoPreço
{{item.product.name}}R$ {{item.product.price}}
Total R$ {{total}}
+
+ + + + + + + + + diff --git a/gestaoRaul/comandas/urls.py b/gestaoRaul/comandas/urls.py index 4b9539a..81d739d 100644 --- a/gestaoRaul/comandas/urls.py +++ b/gestaoRaul/comandas/urls.py @@ -5,6 +5,7 @@ from . import views urlpatterns = [ path('', views.comandas, name='comandas'), path('viewcomanda/', views.viewComanda, name='viewcomanda'), + path('createComanda/', views.createComanda, name='createComanda'), diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 8f5c437..476bde9 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -1,12 +1,14 @@ from django.shortcuts import render, redirect -from comandas.models import Comanda +from comandas.models import Comanda, ProductComanda +from mesas.models import Mesa # Create your views here. def comandas(request): comandas = Comanda.objects.all() - return render(request, 'comandas.html', {'comandas': comandas}) + mesas = Mesa.objects.all() + return render(request, 'comandas.html', {'comandas': comandas, 'mesas': mesas}) @@ -15,5 +17,27 @@ def viewComanda(request): id = request.GET.get('parametro') comanda_id = int(id) comanda = Comanda.objects.get(id=comanda_id) + consumo = ProductComanda.objects.filter(comanda=comanda_id) + total = 0 + for produto in consumo: + total += produto.product.price - return render(request, 'viewcomanda.html', {'comanda': comanda}) \ No newline at end of file + return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total}) + + +def addProduct(request): + pass + # id = request.GET.get('parametro') + # comanda_id = int(id) + # comanda = Comanda.objects.get(id=comanda_id) + # return render(request, 'addproduct.html', {'comanda': comanda}) + + +def createComanda(request): + name = request.POST.get('name-comanda') + mesa_id = int(request.POST.get('select-mesa')[0]) + mesa = Mesa.objects.get(id=mesa_id) + comanda = Comanda(name=name, mesa=mesa) + comanda.save() + + return redirect('comandas') \ No newline at end of file diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 7e2788156585a74263a5fe40a5edcbce6a5ee436..b5fae268f7524bc89b891c82ef3f98b77875ebf0 100644 GIT binary patch delta 1144 zcmZvaO-NKx7>3We=T3V3na`kcyiV9?_A}Lt=l;*VfgshQpjB8r?|kohhiA)&XUoT9 zI5V;R5YD{FJle4X-lB@|GJ%hfftPR{Zo_?e0!N@0Sa>=7GhZKn6^?BKlEm#^cebY^ z+t>E{Clsq92eChKSBheJvbO0ARwl1Eos$tlk(={Ph506Y;0jTo%P*P2yDP84O&Ek5 z&;>Ivo!^>Kp)N!)u26)Q*98C3K&u0d_@mG80QcYWOP=FI8Qgox__8!NQ6&llwq^j{RuIa93xw@6o9n-MVZVh)SflDj8{MiK@8!BQd#|+z1ox@R% zB?CdMmAQptsqkY=Dy`xZmJw%HVVTeQ#vSho(ue-+n`%QKx`eguin-`vOKa=KcITHwzX-@=xzv z&sYr9+*0E#Ip6me}|bc<1}m63D$&UhwGMvm!^ ziYv`J(t38B!Uu_!kJI@-1Y9vw4u%%t&ljBsMz|n+u7}0b-|2Jgp!TLU+Rp4la&}FVv5*+ZjRzBsVqnhNUYS$%}+_qDK26M3Gx>} z6c@upIY6R3xv9m8a3M~h&@GnY%#zew97U<=nZ+fkMJpMKc!9!2ypu07`Y6Z%nLG?U SOgxMNj64v?45fiQ0Y(5`%S-Oi%7r9IFV0=alu4w!+J)B6owSm9FAPhC{8e&Er%