Add form css

This commit is contained in:
Edgar P. Burkhart 2022-05-20 21:56:22 +02:00
parent 25482790dc
commit 30db14669f
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
5 changed files with 59 additions and 15 deletions

View file

@ -48,7 +48,7 @@ class Transaction(models.Model):
class TransactionForm(ModelForm): class TransactionForm(ModelForm):
class Meta: class Meta:
model = Transaction model = Transaction
fields = ["name", "description", "value", "date", "category"] fields = ["date", "name", "value", "trader", "category", "description"]
class Invoice(models.Model): class Invoice(models.Model):

View file

@ -0,0 +1,21 @@
form {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: var(--gap);
margin: var(--gap) 0;
}
form label,
form input,
form select {
line-height: 2em;
}
form > .buttons {
grid-column: 1 / -1;
text-align: right;
}
form > .buttons input {
padding: 0 1em;
margin-left: 1em;
}

View file

@ -20,6 +20,8 @@ body {
--bg-01: #dedede; --bg-01: #dedede;
--text-link: #0066ff; --text-link: #0066ff;
--gap: 1em;
} }
h1 { h1 {

View file

@ -43,11 +43,9 @@
{% if categories %} {% if categories %}
<h2>Catégories</h2> <h2>Catégories</h2>
<div id="categories"> <div id="categories">
{% spaceless %}
{% for cat in categories %} {% for cat in categories %}
<a href="{% url 'category' cat.id %}">{{ cat }}</a> <a href="{% url 'category' cat.id %}">{{ cat }}</a>
{% endfor %} {% endfor %}
{% endspaceless %}
</div> </div>
{% endif %} {% endif %}

View file

@ -1,24 +1,47 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% load static %}
{% block link %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'css/form.css' %}" type="text/css" />
{% endblock %}
{% block body %} {% block body %}
<h1>{{ transaction }}</h1> <h1>{{ transaction }}</h1>
<form action="{% url 'update_transaction' transaction.id %}" method="post"> {% spaceless %}
<form id="transaction" action="{% url 'update_transaction' transaction.id %}" method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} {% for field in form %}
<input type="submit" /> {{ field.errors }}
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% endfor %}
<div class="buttons">
<input type="reset" />
<input type="submit" value="Save Transaction" />
</div>
</form> </form>
{% endspaceless %}
<form action="{% url 'add_invoice' transaction.id %}" method="post" enctype="multipart/form-data"> <h2>Invoices</h2>
{% csrf_token %} <div id="invoices">
<ul> {% for inv in invoices %}
{% for inv in invoices %} <div class="invoice">
<li>
<a href="{% url 'invoice' inv.id %}">{{ inv.name }}</a> <a href="{% url 'invoice' inv.id %}">{{ inv.name }}</a>
<a href="{% url 'del_invoice' transaction.id inv.id %}">x</a> <a href="{% url 'del_invoice' transaction.id inv.id %}">x</a>
</li> </div>
{% endfor %} {% endfor %}
<li>{{ invoice_form.as_p }}<input type="submit" /></li> </div>
</ul>
<h3>Add Invoice</h3>
<form action="{% url 'add_invoice' transaction.id %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
{% for field in invoice_form %}
{{ field.errors }}
<label for="{{ field.id_for_label }}">{{field.label }}</label>
{{ field }}
{% endfor %}
<div class="buttons"><input type="submit" value="Add Invoice" /></div>
</form> </form>
{% endblock %} {% endblock %}