alter: alteracao metodo POST osbOrder

This commit is contained in:
2025-03-28 13:20:20 -03:00
parent 8d31a83b13
commit bb51147d99
11 changed files with 73 additions and 40 deletions

View File

@@ -93,21 +93,21 @@ def addProduct(request, product_id, comanda_id):
return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'config':config, 'valores':valores,'parcials':parcial,'consumo': consumo,'comanda':comanda})
@group_required(groupName='Garçom')
def editOrders(request, productComanda_id, obs):
order = Order.objects.get(productComanda=productComanda_id)
order.obs = obs
order.save()
msg = JsonResponse({
'type': 'broadcast',
'message': obs,
'local':'cozinha',
'tipo':'edit',
'id':order.id,
'speak': f'Pedido alterado! {order.id_product.name}, é {obs}.'
})
asyncio.run(enviar_mensagem(msg))
return JsonResponse({'status': 'ok'})
# @group_required(groupName='Garçom')
# def editOrders(request, productComanda_id, obs):
# order = Order.objects.get(productComanda=productComanda_id)
# order.obs = obs
# order.save()
# msg = JsonResponse({
# 'type': 'broadcast',
# 'message': obs,
# 'local':'cozinha',
# 'tipo':'edit',
# 'id':order.id,
# 'speak': f'Pedido alterado! {order.id_product.name}, é {obs}.'
# })
# # asyncio.run(enviar_mensagem(msg))
# return JsonResponse({'status': 'ok'})
@group_required(groupName='Garçom')

View File

@@ -87,7 +87,7 @@ Detalhes {{comanda.name}}
{{item.product.name}}
{% if item.product.cuisine == True %}
<input hidden id="{{item.id}}-obsOrder" type="order" value="{{item.id | obsOrder}}">
<span data-tooltip="{{item.id | obsOrder}}" data-flow="top">
<span id="tooltip-id-{{item.id}}" data-tooltip="{{item.id | obsOrder}}" data-flow="top">
<img
onclick="openModalObs({{item.id}})"
@@ -106,9 +106,6 @@ Detalhes {{comanda.name}}
</td>
<td>R$ {{item.product.price}}</td>
{% if comanda.status != 'OPEN'%}
{% else %}
<td>

View File

@@ -11,6 +11,7 @@ urlpatterns = [
path('editComanda/', views.editComanda, name='editComanda'),
path('addContaCliente/', views.addContaCliente, name='addContaCliente'),
path('notificacao/', views.notificacao, name='notificacao'),
path('editOrders/<int:productComanda_id>/<str:obs>', views.editOrders, name='editOrders'),
@@ -22,7 +23,6 @@ htmx_urlpatterns = [
path('listProduct/<int:comanda_id>/', htmx_views.listProduct, name='listProduct'),
path('addProduct<int:product_id>/<int:comanda_id>/', htmx_views.addProduct, name='addProduct'),
path('removeProductComanda<int:productComanda_id>/', htmx_views.removeProductComanda, name='removeProductComanda'),
path('editOrders/<int:productComanda_id>/<str:obs>', htmx_views.editOrders, name='editOrders'),
path('closeComanda<int:comanda_id>/', htmx_views.closeComanda, name='closeComanda'),
path('reopenComanda<int:comanda_id>/', htmx_views.reopenComanda, name='reopenComanda'),
path('paymentComanda<int:comanda_id>/', htmx_views.paymentComanda, name='paymentComanda'),

View File

@@ -138,3 +138,21 @@ def notificacao(request):
'notificacao': 'false',
'pronto':len(ordersPronto),
})
@group_required(groupName='Garçom')
def editOrders(request, productComanda_id, obs):
order = Order.objects.get(productComanda=productComanda_id)
order.obs = obs
order.save()
msg = JsonResponse({
'type': 'broadcast',
'message': obs,
'local':'cozinha',
'tipo':'edit',
'id':order.id,
'speak': f'Pedido alterado! {order.id_product.name}, é {obs}.'
})
# asyncio.run(enviar_mensagem(msg))
return JsonResponse({'status': 'ok', 'obs':order.obs})