Spaces:
Running
Running
Se usa controlador en vista para crear sesioes
Browse files
tecnicas/controllers/ordenes_controller.py
CHANGED
|
@@ -10,6 +10,7 @@ class OrdenesController():
|
|
| 10 |
orders: list[Orden]
|
| 11 |
orders_save: list[Orden]
|
| 12 |
positions: list[Posicion]
|
|
|
|
| 13 |
|
| 14 |
def __init__(self, raw_orders: list[list[dict]], list_products: list[Producto], technique: Tecnica):
|
| 15 |
self.products = list_products
|
|
|
|
| 10 |
orders: list[Orden]
|
| 11 |
orders_save: list[Orden]
|
| 12 |
positions: list[Posicion]
|
| 13 |
+
savePostions: list[Posicion]
|
| 14 |
|
| 15 |
def __init__(self, raw_orders: list[list[dict]], list_products: list[Producto], technique: Tecnica):
|
| 16 |
self.products = list_products
|
tecnicas/controllers/productos_controller.py
CHANGED
|
@@ -38,4 +38,4 @@ class ProductosController():
|
|
| 38 |
self.products_save = Producto.objects.bulk_create(self.list_product)
|
| 39 |
return self.products_save
|
| 40 |
except DatabaseError as error:
|
| 41 |
-
return
|
|
|
|
| 38 |
self.products_save = Producto.objects.bulk_create(self.list_product)
|
| 39 |
return self.products_save
|
| 40 |
except DatabaseError as error:
|
| 41 |
+
return controller_error(error)
|
tecnicas/views/create_session.py
CHANGED
|
@@ -2,7 +2,7 @@ from django.http import HttpRequest, JsonResponse
|
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
from ..utils import general_error
|
| 5 |
-
from ..controllers import TecnicaController, EscalaController, ProductosController
|
| 6 |
|
| 7 |
|
| 8 |
def createSession(req: HttpRequest):
|
|
@@ -63,7 +63,30 @@ def createSession(req: HttpRequest):
|
|
| 63 |
technique=technique
|
| 64 |
)
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
raw_sort_codes = data_codes["sort_codes"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
return JsonResponse({"message": "sesion creada", "data": {"session_id": "asd548ad4a"}})
|
| 69 |
-
return general_error("ha orcurrido un error inesperado")
|
|
|
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
from ..utils import general_error
|
| 5 |
+
from ..controllers import TecnicaController, EscalaController, ProductosController, OrdenesController
|
| 6 |
|
| 7 |
|
| 8 |
def createSession(req: HttpRequest):
|
|
|
|
| 63 |
technique=technique
|
| 64 |
)
|
| 65 |
|
| 66 |
+
controllerProducts.setProductsNoSave()
|
| 67 |
+
saved_prodcuts = controllerProducts.saveProducts()
|
| 68 |
+
if saved_prodcuts["error"]:
|
| 69 |
+
return general_error(saved_tags["error"])
|
| 70 |
+
|
| 71 |
raw_sort_codes = data_codes["sort_codes"]
|
| 72 |
+
controllerOrdes = OrdenesController(
|
| 73 |
+
raw_orders=raw_sort_codes,
|
| 74 |
+
list_products=saved_prodcuts,
|
| 75 |
+
technique=technique
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
controllerOrdes.setOrders()
|
| 79 |
+
saved_orders = controllerOrdes.saveOrders()
|
| 80 |
+
if saved_orders["error"]:
|
| 81 |
+
return general_error(saved_orders["error"])
|
| 82 |
+
|
| 83 |
+
seded_positions = controllerOrdes.setPositions()
|
| 84 |
+
if seded_positions["error"]:
|
| 85 |
+
return general_error(seded_positions["error"])
|
| 86 |
+
|
| 87 |
+
saved_postions = controllerOrdes.savePostions()
|
| 88 |
+
if saved_prodcuts["error"]:
|
| 89 |
+
return general_error(saved_prodcuts["error"])
|
| 90 |
|
| 91 |
return JsonResponse({"message": "sesion creada", "data": {"session_id": "asd548ad4a"}})
|
| 92 |
+
return general_error("ha orcurrido un error inesperado")
|