<commit_before>{% extends "checkout/layout.html" %}
{% load currency_filters %}

{% block title %}
Basket | {{ block.super }}
{% endblock %}

{% block header %}
<div class="page-header">
    <h1>Basket</h1>
</div>
{% endblock header %}


{% block content %}

{% if request.basket.lines.count %}

<form action="." method="post" class="basket_summary">
    {% csrf_token %}
	
	{{ formset.management_form }}

	<table class="table table-striped table-bordered">
		<thead>
			<tr>
				<th>Product</th>
				<th>Availability</th>
				<th>Quantity</th>
				<th>Unit Price Excl. Tax</th>
				<th>Tax</th>
				<th>Line Price Excl. Tax</th>
				<th>Line Price Incl. Tax</th>
				<th>Save for later&hellip;</th>
				<th>Delete?</th>				
			</tr>
		</thead>
		<tbody>
			{% for form in formset %}
			<tr>
				<td>{{ form.id }}<a href="{{ form.instance.product.get_absolute_url }}">{{ form.instance.description }}</a></td>
				<td>{{ form.instance.product.stockrecord.availability }}</td>
				<td>{{ form.quantity }}</td>
		        <td>{{ form.instance.unit_price_excl_tax|currency }}</td>
		        <td>{{ form.instance.unit_tax|currency }}</td>
		        <td>{{ form.instance.line_price_excl_tax|currency }}</td>
		        <td>{{ form.instance.line_price_incl_tax|currency }}</td>
				<td>{{ form.save_for_later }}</td>
				<td>{{ form.DELETE }}</td>
			</tr>
			{% endfor %}
			{% for discount in basket.discounts %}
		    <tr>
		        <td colspan="6">{{ discount.name }}</td>
		        <td colspan="3">-{{ discount.discount|currency }}</td>
		    </tr>
		    {% endfor %}
		    <tr>
		        <td colspan="5">Total</td>
		        <td>{{ request.basket.total_excl_tax|currency }}</td>
		        <td colspan="3">{{ basket.total_incl_tax|currency }}</td>
		    </tr>
		</tbody>
	</table>
	

	<div class="form-actions">
	    <input type="submit" value="Apply Changes" class="btn"/>
	    <a href="{% url checkout:index %}" class="pull-right btn btn-primary">Checkout</a>
	</div>

</form>

{% else %}

<p>Your basket is empty, you should probably add some items to buy.</p>

{% endif %}

{% if request.basket.pk %}
<h4>Basket vouchers</h4>
<ul>
{% for voucher in basket.vouchers.all %}
    <li>
        <form action="{% url basket:vouchers-remove voucher.id %}" method="POST">
            {% csrf_token %}
            {{ voucher.name }} ({{ voucher.code }})
            <input type="submit" value="Remove" class="btn" />
        </form>
    </li>
{% endfor %}
</ul>
{% endif %}

<form action="{% url basket:vouchers-add %}" method="post" class="form-horizontal">
    {% csrf_token %}
	{% include "partials/form_fields.html" with form=voucher_form %}
    <div class="form-actions">
        <input type="submit" value="Add voucher" class="btn"/>
    </div>
</form>


{% if saved_formset %}

<div class="page-header">
    <h2>To buy later</h2>
</div>

<form action="{% url basket:saved %}" method="post" class="form-stacked later_summary">
	{% csrf_token %}
	
	{{ saved_formset.management_form }}
	
	<table class="bordered-table zebra-striped">
		<thead>
			<tr>
				<th>Product</th>
				<th>Unit Price Excl. Tax</th>
				<th>Tax</th>
				<th>Line Price Excl. Tax</th>
				<th>Line Price Incl. Tax</th>
				<th>Move to basket&hellip;</th>			
				<th>Delete?</th>
			</tr>
		</thead>
		<tbody>
			{% for form in saved_formset %}
			<tr>
				<td>{{ form.id }}<a href="{{ form.instance.product.get_absolute_url }}">{{ form.instance.description }}</a></td>
		        <td>{{ form.instance.unit_price_excl_tax|currency }}</td>
		        <td>{{ form.instance.unit_tax|currency }}</td>
		        <td>{{ form.instance.line_price_excl_tax|currency }}</td>
		        <td>{{ form.instance.line_price_incl_tax|currency }}</td>
				<td>{{ form.move_to_basket }}</td>
				<td>{{ form.DELETE }}</td>
			</tr>
			{% endfor %}
		</tbody>
	</table>

	

	<div class="form-actions">
   	    <input type="submit" value="Apply Changes" class="btn" />
   	</div>

</form>

{% endif %}

{% endblock content %}
<commit_msg>Fix #0055826 - removed voucher form when basket is empty<commit_after>{% extends "checkout/layout.html" %}
{% load currency_filters %}

{% block title %}
Basket | {{ block.super }}
{% endblock %}

{% block header %}
<div class="page-header">
    <h1>Basket</h1>
</div>
{% endblock header %}


{% block content %}

{% if request.basket.lines.count %}

<form action="." method="post" class="basket_summary">
    {% csrf_token %}

    {{ formset.management_form }}

    <table class="table table-striped table-bordered">
        <thead>
        <tr>
            <th>Product</th>
            <th>Availability</th>
            <th>Quantity</th>
            <th>Unit Price Excl. Tax</th>
            <th>Tax</th>
            <th>Line Price Excl. Tax</th>
            <th>Line Price Incl. Tax</th>
            <th>Save for later&hellip;</th>
            <th>Delete?</th>
        </tr>
        </thead>
        <tbody>
        {% for form in formset %}
        <tr>
            <td>{{ form.id }}<a href="{{ form.instance.product.get_absolute_url }}">{{ form.instance.description }}</a>
            </td>
            <td>{{ form.instance.product.stockrecord.availability }}</td>
            <td>{{ form.quantity }}</td>
            <td>{{ form.instance.unit_price_excl_tax|currency }}</td>
            <td>{{ form.instance.unit_tax|currency }}</td>
            <td>{{ form.instance.line_price_excl_tax|currency }}</td>
            <td>{{ form.instance.line_price_incl_tax|currency }}</td>
            <td>{{ form.save_for_later }}</td>
            <td>{{ form.DELETE }}</td>
        </tr>
        {% endfor %}
        {% for discount in basket.discounts %}
        <tr>
            <td colspan="6">{{ discount.name }}</td>
            <td colspan="3">-{{ discount.discount|currency }}</td>
        </tr>
        {% endfor %}
        <tr>
            <td colspan="5">Total</td>
            <td>{{ request.basket.total_excl_tax|currency }}</td>
            <td colspan="3">{{ basket.total_incl_tax|currency }}</td>
        </tr>
        </tbody>
    </table>


    <div class="form-actions">
        <input type="submit" value="Apply Changes" class="btn"/>
        <a href="{% url checkout:index %}" class="pull-right btn btn-primary">Checkout</a>
    </div>

</form>

{% if request.basket.pk %}
<h4>Basket vouchers</h4>
<ul>
    {% for voucher in basket.vouchers.all %}
    <li>
        <form action="{% url basket:vouchers-remove voucher.id %}" method="POST">
            {% csrf_token %}
            {{ voucher.name }} ({{ voucher.code }})
            <input type="submit" value="Remove" class="btn"/>
        </form>
    </li>
    {% endfor %}
</ul>
{% endif %}

<form action="{% url basket:vouchers-add %}" method="post" class="form-horizontal">
    {% csrf_token %}
    {% include "partials/form_fields.html" with form=voucher_form %}
    <div class="form-actions">
        <input type="submit" value="Add voucher" class="btn"/>
    </div>
</form>

{% else %}

<p>Your basket is empty, you should probably add some items to buy.</p>

{% endif %}

{% if saved_formset %}

<div class="page-header">
    <h2>To buy later</h2>
</div>

<form action="{% url basket:saved %}" method="post" class="form-stacked later_summary">
    {% csrf_token %}

    {{ saved_formset.management_form }}

    <table class="bordered-table zebra-striped">
        <thead>
        <tr>
            <th>Product</th>
            <th>Unit Price Excl. Tax</th>
            <th>Tax</th>
            <th>Line Price Excl. Tax</th>
            <th>Line Price Incl. Tax</th>
            <th>Move to basket&hellip;</th>
            <th>Delete?</th>
        </tr>
        </thead>
        <tbody>
        {% for form in saved_formset %}
        <tr>
            <td>{{ form.id }}<a href="{{ form.instance.product.get_absolute_url }}">{{ form.instance.description }}</a>
            </td>
            <td>{{ form.instance.unit_price_excl_tax|currency }}</td>
            <td>{{ form.instance.unit_tax|currency }}</td>
            <td>{{ form.instance.line_price_excl_tax|currency }}</td>
            <td>{{ form.instance.line_price_incl_tax|currency }}</td>
            <td>{{ form.move_to_basket }}</td>
            <td>{{ form.DELETE }}</td>
        </tr>
        {% endfor %}
        </tbody>
    </table>


    <div class="form-actions">
        <input type="submit" value="Apply Changes" class="btn"/>
    </div>

</form>

{% endif %}

{% endblock content %}

{'fraction_non_alphanumeric': 0.1959290560647542, 'fraction_numerical': 0.0032139031067730034, 'mean_word_length': 2.5022926219258026, 'pattern_counts': {'":': 0, '<': 279, '<?xml version=': 0, '>': 279, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7201658', 'n_tokens_mistral': 3210, 'n_tokens_neox': 2848, 'n_words': 590}