Complex form
This commit is contained in:
82
project/main/views/complex_form/views.py
Normal file
82
project/main/views/complex_form/views.py
Normal file
@ -0,0 +1,82 @@
|
||||
from typing import Any
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from project.main.views.complex_form.state_models import CheckboxState, FormState, SelectState, RouteModuleState
|
||||
from project.main.views.demo_view_base import DemoViewBase
|
||||
|
||||
|
||||
|
||||
|
||||
# def control_state(state: FormState) -> None:
|
||||
# state.smart_routing.enabled = state.route_module.checked
|
||||
# state.geo_routing.enabled = state.route_module.checked
|
||||
# state.warehouse.enabled = state.route_module.checked
|
||||
# state.custom_forms_in_routing.enabled = state.route_module.checked
|
||||
#
|
||||
# state.predictive_pickup.visible = (
|
||||
# state.smart_routing.checked and state.smart_routing.enabled
|
||||
# )
|
||||
# state.automatic_planning.visible = (
|
||||
# state.smart_routing.checked and state.smart_routing.enabled
|
||||
# )
|
||||
# # state.prekitting_to_box.visible = (
|
||||
# # state.use_packing_model_per_route.enabled
|
||||
# # and state.use_packing_model_per_route.checked
|
||||
# # )
|
||||
# # state.prekitting_to_pallet.visible = (
|
||||
# # state.use_packing_model_per_route.enabled
|
||||
# # and state.use_packing_model_per_route.checked
|
||||
# # )
|
||||
# # state.real_time_stock.visible = (
|
||||
# # state.use_packing_model_per_route.enabled
|
||||
# # and state.use_packing_model_per_route.checked
|
||||
# # )
|
||||
# state.end_warehouse_tracking.visible = state.warehouse.checked
|
||||
#
|
||||
# print(state)
|
||||
# print("-" * 100)
|
||||
|
||||
|
||||
class ComplexFormView(DemoViewBase):
|
||||
template_name = "main/complex_form/container.html"
|
||||
active_section = "complex-form"
|
||||
title = "Complex Form"
|
||||
|
||||
def get_context_data(self, **kwargs) -> dict[str, Any]:
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
state = FormState(
|
||||
route_module=RouteModuleState.from_form(values={})
|
||||
)
|
||||
# control_state(state)
|
||||
|
||||
context.update(
|
||||
{
|
||||
"form_state": state,
|
||||
}
|
||||
)
|
||||
return context
|
||||
|
||||
def post(self, request: WSGIRequest, *args, **kwargs) -> HttpResponse:
|
||||
...
|
||||
|
||||
|
||||
class ComplexFormHandleView(TemplateView):
|
||||
template_name = "main/complex_form/route_module.html"
|
||||
|
||||
def post(self, request: WSGIRequest, *args, **kwargs) -> HttpResponse:
|
||||
print(request.POST)
|
||||
state = FormState(
|
||||
route_module=RouteModuleState.from_form(values=request.POST),
|
||||
)
|
||||
# state = route_module_form_to_state(values=request.POST)
|
||||
# control_state(state)
|
||||
|
||||
return self.render_to_response(
|
||||
context={
|
||||
"form_state": state,
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user