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 Meta:
model = Transaction
fields = ["name", "description", "value", "date", "category"]
fields = ["date", "name", "value", "trader", "category", "description"]
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;
--text-link: #0066ff;
--gap: 1em;
}
h1 {

View file

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

View file

@ -1,24 +1,47 @@
{% extends "main/base.html" %}
{% load static %}
{% block link %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'css/form.css' %}" type="text/css" />
{% endblock %}
{% block body %}
<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 %}
{{ form.as_p }}
<input type="submit" />
{% for field in form %}
{{ 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>
{% endspaceless %}
<form action="{% url 'add_invoice' transaction.id %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<ul>
{% for inv in invoices %}
<li>
<h2>Invoices</h2>
<div id="invoices">
{% for inv in invoices %}
<div class="invoice">
<a href="{% url 'invoice' inv.id %}">{{ inv.name }}</a>
<a href="{% url 'del_invoice' transaction.id inv.id %}">x</a>
</li>
{% endfor %}
<li>{{ invoice_form.as_p }}<input type="submit" /></li>
</ul>
</div>
{% endfor %}
</div>
<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>
{% endblock %}