feat: remplazando formulario compra manual por formulario django
This commit is contained in:
parent
619fa0fcf9
commit
32b5a6ec36
@ -1,12 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<form method="POST">
|
|
||||||
{% csrf_token %}
|
|
||||||
{{ sale_form}}
|
|
||||||
{{ linea_formset.management_form }}
|
|
||||||
{% for form in linea_formset %}
|
|
||||||
<table style="border: solid 1px blue; margin: 10px">
|
|
||||||
{{ form.as_table }}
|
|
||||||
</table>
|
|
||||||
{% endfor %}
|
|
||||||
<br/><button name="form" type="submit" >Comprar</button>
|
|
||||||
</form>
|
|
@ -1,43 +1,12 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<form action="{% url 'buy'%}" method="POST">
|
<form method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<fieldset>
|
{{ sale_form}}
|
||||||
<legend>Purchase</legend>
|
{{ linea_formset.management_form }}
|
||||||
<label for="customer">Customer</label>:
|
{% for form in linea_formset %}
|
||||||
<input type="search" name="customer" id="customer"/>
|
<table style="border: solid 1px blue; margin: 10px">
|
||||||
|
{{ form.as_table }}
|
||||||
<label for="date">Date</label>:
|
</table>
|
||||||
<input type="date" name="date" id="date"/>
|
{% endfor %}
|
||||||
|
<br/><button name="form" type="submit" >Comprar</button>
|
||||||
<label for="description">Description</label>:
|
|
||||||
<input type="text" name="description" id="description"/>
|
|
||||||
|
|
||||||
<fieldset>
|
|
||||||
<legend>Purchase Line</legend>
|
|
||||||
<label for="product">Product</label>:
|
|
||||||
<input type="search" name="product" id="product"/>
|
|
||||||
|
|
||||||
<label for="unit_price">Unit Price</label>:
|
|
||||||
<input type="number" name="unit_price" min="0" id="unit_price"/>
|
|
||||||
|
|
||||||
<label for="quantity">Quantity</label>:
|
|
||||||
<input type="number" name="quantity" min="0" id="quantity"/>
|
|
||||||
|
|
||||||
<label for="subtotal">Subtotal</label>:
|
|
||||||
<input type="number" name="subtotal" min="0" id="line_amount"/>
|
|
||||||
</fieldset>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label for="total_amount">Total</label>:
|
|
||||||
<input type="number" name="total_amount" min="0" id="total_amount"/>
|
|
||||||
|
|
||||||
<label for="Paid">Paid:</label>
|
|
||||||
<select id="paid" name="paid">
|
|
||||||
<option value="yes">Yes</option>
|
|
||||||
<option value="no">No</option>
|
|
||||||
</select>
|
|
||||||
</fieldset>
|
|
||||||
<div class="button-container">
|
|
||||||
<button name="form" type="submit">Enviar</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -6,7 +6,6 @@ app_name = 'don_confiao'
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="wellcome"),
|
path("", views.index, name="wellcome"),
|
||||||
path("comprar", views.buy, name="buy"),
|
path("comprar", views.buy, name="buy"),
|
||||||
path("comprar_django", views.django_buy, name="django_buy"),
|
|
||||||
path("compras", views.purchases, name="purchases"),
|
path("compras", views.purchases, name="purchases"),
|
||||||
path("productos", views.products, name="products"),
|
path("productos", views.products, name="products"),
|
||||||
path("importar_productos", views.import_products, name="import_products")
|
path("importar_productos", views.import_products, name="import_products")
|
||||||
|
@ -11,15 +11,7 @@ import io
|
|||||||
def index(request):
|
def index(request):
|
||||||
return render(request, 'don_confiao/index.html')
|
return render(request, 'don_confiao/index.html')
|
||||||
|
|
||||||
|
|
||||||
def buy(request):
|
def buy(request):
|
||||||
context = {}
|
|
||||||
if request.POST:
|
|
||||||
raise Exception(request.POST)
|
|
||||||
return render(
|
|
||||||
request, 'don_confiao/purchase.html', context)
|
|
||||||
|
|
||||||
def django_buy(request):
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
sale_form = PurchaseForm(request.POST)
|
sale_form = PurchaseForm(request.POST)
|
||||||
sale_linea_form = LineaFormSet(request.POST)
|
sale_linea_form = LineaFormSet(request.POST)
|
||||||
@ -33,7 +25,7 @@ def django_buy(request):
|
|||||||
sale_linea_form = LineaFormSet()
|
sale_linea_form = LineaFormSet()
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
'don_confiao/django_purchase.html',
|
'don_confiao/purchase.html',
|
||||||
{
|
{
|
||||||
'sale_form': sale_form,
|
'sale_form': sale_form,
|
||||||
'linea_formset': sale_linea_form
|
'linea_formset': sale_linea_form
|
||||||
|
Loading…
Reference in New Issue
Block a user