feat: remplazando formulario compra manual por formulario django
This commit is contained in:
		@@ -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>
 | 
			
		||||
<form action="{% url 'buy'%}" method="POST">
 | 
			
		||||
<form method="POST">
 | 
			
		||||
    {% csrf_token %}
 | 
			
		||||
    <fieldset>
 | 
			
		||||
        <legend>Purchase</legend>
 | 
			
		||||
        <label for="customer">Customer</label>:
 | 
			
		||||
        <input type="search" name="customer" id="customer"/>
 | 
			
		||||
 | 
			
		||||
        <label for="date">Date</label>:
 | 
			
		||||
        <input type="date" name="date" id="date"/>
 | 
			
		||||
 | 
			
		||||
        <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>
 | 
			
		||||
        {{ 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>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,6 @@ app_name = 'don_confiao'
 | 
			
		||||
urlpatterns = [
 | 
			
		||||
    path("", views.index, name="wellcome"),
 | 
			
		||||
    path("comprar", views.buy, name="buy"),
 | 
			
		||||
    path("comprar_django", views.django_buy, name="django_buy"),
 | 
			
		||||
    path("compras", views.purchases, name="purchases"),
 | 
			
		||||
    path("productos", views.products, name="products"),
 | 
			
		||||
    path("importar_productos", views.import_products, name="import_products")
 | 
			
		||||
 
 | 
			
		||||
@@ -11,15 +11,7 @@ import io
 | 
			
		||||
def index(request):
 | 
			
		||||
    return render(request, 'don_confiao/index.html')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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":
 | 
			
		||||
        sale_form = PurchaseForm(request.POST)
 | 
			
		||||
        sale_linea_form = LineaFormSet(request.POST)
 | 
			
		||||
@@ -33,7 +25,7 @@ def django_buy(request):
 | 
			
		||||
        sale_linea_form = LineaFormSet()
 | 
			
		||||
    return render(
 | 
			
		||||
        request,
 | 
			
		||||
        'don_confiao/django_purchase.html',
 | 
			
		||||
        'don_confiao/purchase.html',
 | 
			
		||||
        {
 | 
			
		||||
            'sale_form': sale_form,
 | 
			
		||||
            'linea_formset': sale_linea_form
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user