Globally improve display

This commit is contained in:
Gabriel Augendre 2022-04-25 19:54:57 +02:00
parent ef4672ca15
commit 08acd02d3b
9 changed files with 47 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -7,6 +7,15 @@
<title>Checkout</title> <title>Checkout</title>
<link href="{% static "vendor/bootstrap-5.1.3-dist/css/bootstrap.min.css" %}" <link href="{% static "vendor/bootstrap-5.1.3-dist/css/bootstrap.min.css" %}"
rel="stylesheet"> rel="stylesheet">
<style>
body {
margin-bottom: 2em;
}
</style>
<script defer src="{% static "vendor/fontawesome-6.1.1-free/brands.min.js" %}"></script>
<script defer src="{% static "vendor/fontawesome-6.1.1-free/solid.min.js" %}"></script>
<script defer src="{% static "vendor/fontawesome-6.1.1-free/fontawesome.min.js" %}"></script>
{% block extrahead %} {% block extrahead %}
{% endblock %} {% endblock %}
</head> </head>

View file

@ -19,7 +19,7 @@ class BasketForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.helper = FormHelper() self.helper = FormHelper()
self.helper.add_input(Submit("submit", "Submit")) self.helper.add_input(Submit("submit", "Save"))
self.helper.layout = Layout() self.helper.layout = Layout()
products = {} products = {}
basket = kwargs.get("instance") basket = kwargs.get("instance")

View file

@ -2,19 +2,18 @@
{% load crispy_forms_tags purchase %} {% load crispy_forms_tags purchase %}
{% block content %} {% block content %}
{% if object %} {% if object %}
<h1>{{ object }} <span class="badge bg-secondary">{{ object.price|currency }}</span></h1>
<p class="metadata">
{{ object.created_at }}
</p>
{% if not object.payment_method %} {% if not object.payment_method %}
<div class="alert alert-warning" role="alert">Missing payment method.</div> <div class="alert alert-danger" role="alert">Missing payment method.</div>
{% endif %} {% endif %}
<h1>{{ object }}</h1>
<p>{{ object.created_at }}</p>
{% else %} {% else %}
<h1>New basket</h1> <h1>New basket</h1>
{% endif %} {% endif %}
{% crispy form %} {% crispy form %}
{% if object %} {% if object %}
<div>
Price: {{ object.price|currency }}
</div>
<a href="{% url "purchase:new" %}" class="btn btn-secondary">New</a> <a href="{% url "purchase:new" %}" class="btn btn-secondary">New</a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -11,17 +11,19 @@
<p class="card-text"> <p class="card-text">
{{ basket.items.count }} items<br> {{ basket.items.count }} items<br>
{{ basket.price|currency }}<br> {{ basket.price|currency }}<br>
{{ basket.payment_method }} {{ basket.payment_method|default:"-" }}
</p> </p>
<div class="btn-group btn-group-sm">
{% if perms.purchase.change_basket %} {% if perms.purchase.change_basket %}
<a href="{% url "purchase:update" basket.id %}" class="btn btn-sm btn-primary">Edit</a> <a href="{% url "purchase:update" basket.id %}" class="btn btn-primary"><i class="fa-solid fa-pen-to-square"></i></a>
{% endif %} {% endif %}
{% if perms.purchase.delete_basket %} {% if perms.purchase.delete_basket %}
<a href="{% url "purchase:delete" basket.id %}" class="btn btn-sm btn-danger">Delete</a> <a href="{% url "purchase:delete" basket.id %}" class="btn btn-danger"><i class="fa-solid fa-trash"></i></a>
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
</div>
{% endfor %} {% endfor %}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -1,15 +1,15 @@
{% load crispy_forms_field %} {% load crispy_forms_field %}
<div class="col"> <div class="col">
<div class="card h-100"> <div class="card h-100 {% if field.value %}bg-success text-white{% endif %}">
<div class="card-header {% if field.value %}bg-success text-white{% endif %}">{{ product.name }}</div>
{% if product.image %} {% if product.image %}
<img src="{{ product.image.url }}" class="card-img"> <img src="{{ product.image.url }}" class="card-img">
{% endif %} {% endif %}
<div class="card-body"> <div class="card-body">
<h4 class="card-title">{{ product.name }}</h4>
<div class="input-group"> <div class="input-group">
<button class="btn btn-danger" type="button" onclick="decrementValue('{{ field.id_for_label }}')">-</button> <button class="btn btn-danger" type="button" onclick="decrementValue('{{ field.id_for_label }}')"><i class="fa-solid fa-minus"></i></button>
{% crispy_field field 'class' 'form-control' %} {% crispy_field field 'class' 'form-control' %}
<button class="btn btn-success" type="button" onclick="incrementValue('{{ field.id_for_label }}')">+</button> <button class="btn btn-success {% if field.value %}border-white{% endif %}" type="button" onclick="incrementValue('{{ field.id_for_label }}')"><i class="fa-solid fa-plus"></i></button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -3,7 +3,7 @@
<table class="table table-hover table-sm"> <table class="table table-hover table-sm">
<thead><tr> <thead><tr>
<th scope="col">Product</th> <th scope="col">Product</th>
<th scope="col">Sold</th> <th scope="col"># sold</th>
<th scope="col">Turnover</th> <th scope="col">Turnover</th>
</tr></thead> </tr></thead>
<tbody> <tbody>