diff options
Diffstat (limited to 'alphabetlearning/templates')
4 files changed, 68 insertions, 13 deletions
diff --git a/alphabetlearning/templates/base.html b/alphabetlearning/templates/base.html index faadcd5..1bb67d4 100644 --- a/alphabetlearning/templates/base.html +++ b/alphabetlearning/templates/base.html @@ -109,6 +109,35 @@ <a class="nav-link text-gray fw-bold" href="{% url "account_logout" %}">Log out</a> {% endif %} </li> + <li class="nav-item"> + + {% if request.user.shoppingcart %} + + <div class="mx-2 gray-icon"> + <a href="{% url "payments:cart_detail" %}" class="full-basket-button"> + <span class="fw-bold px-1"> + Items in cart ( + {{ request.user.shoppingcart.items.count }} + ) + </span> + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-bag" viewBox="0 0 16 16"> + <path d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1m3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4zM2 5h12v9a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z"/> + </svg> + </a> + </div> + + {% else %} + + <div class="mx-2 gray-icon"> + <button class="empty-basket-button"><span class="fw-bold px-1">Empty Basket</span> + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-bag-x" viewBox="0 0 16 16"> + <path fill-rule="evenodd" d="M6.146 8.146a.5.5 0 0 1 .708 0L8 9.293l1.146-1.147a.5.5 0 1 1 .708.708L8.707 10l1.147 1.146a.5.5 0 0 1-.708.708L8 10.707l-1.146 1.147a.5.5 0 0 1-.708-.708L7.293 10 6.146 8.854a.5.5 0 0 1 0-.708"/> + <path d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1m3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4zM2 5h12v9a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z"/> + </svg> + </button> + </div> + {% endif %} + </li> </ul> </div> </div> diff --git a/alphabetlearning/templates/resources/resource_card_featured.html b/alphabetlearning/templates/resources/resource_card_featured.html index c83ac0f..0782b0c 100644 --- a/alphabetlearning/templates/resources/resource_card_featured.html +++ b/alphabetlearning/templates/resources/resource_card_featured.html @@ -32,10 +32,17 @@ {% endif %} <div class="d-flex flex-row justify-content-between align-items-end mt-2"> <p class="card-text m-1"><small class="text-muted">1 credit</small></p> - <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> - {% csrf_token %} - <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> - </form> + {% if resource.in_cart %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0" disabled>In basket</button> + </form> + {% else %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> + </form> + {% endif %} </div> </div> diff --git a/alphabetlearning/templates/resources/resource_card_standard.html b/alphabetlearning/templates/resources/resource_card_standard.html index 9850117..640f75d 100644 --- a/alphabetlearning/templates/resources/resource_card_standard.html +++ b/alphabetlearning/templates/resources/resource_card_standard.html @@ -37,10 +37,20 @@ </div> <div class="d-flex flex-row justify-content-between align-items-end mt-2"> <p class="card-text m-1"><small class="text-muted">1 credit</small></p> - <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> - {% csrf_token %} - <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> - </form> + + {% if resource.in_cart %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0" disabled>In basket</button> + </form> + {% else %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="POST"> + {% csrf_token %} + <button type="submit" class="btn btn-success fs-6 px-2 py-0">Add to basket</button> + </form> + {% endif %} + + </div> </div> </div> diff --git a/alphabetlearning/templates/resources/resource_detail.html b/alphabetlearning/templates/resources/resource_detail.html index 6c6ceda..b92ba52 100644 --- a/alphabetlearning/templates/resources/resource_detail.html +++ b/alphabetlearning/templates/resources/resource_detail.html @@ -48,11 +48,20 @@ </div> <div class="row align-items-end"> <div class="my-4 d-flex justify-content-center"> - <form action="{% url 'payments:add_to_cart' resource.id %}" method="get" accept-charset="utf-8"> - <button class="btn btn-primary w-100"> - Add to cart - </button> - </form> + {% if resource.in_cart %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="get" accept-charset="utf-8"> + <button class="btn btn-primary w-100" disabled> + In basket + </button> + </form> + {% else %} + <form action="{% url 'payments:add_to_basket' resource.id %}" method="get" accept-charset="utf-8"> + <button class="btn btn-primary w-100"> + Add to basket + </button> + </form> + + {% endif %} </div> </div> </div> |