costs should work so far
This commit is contained in:
parent
fdacc9adf9
commit
c06acb284a
6 changed files with 59 additions and 20 deletions
|
@ -22,7 +22,7 @@ class Costs(models.Model):
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
default="0.00",
|
default="0.00",
|
||||||
verbose_name=_("Betrag"))
|
verbose_name=_("Betrag"))
|
||||||
created = models.DateTimeField(
|
created = models.DateField(
|
||||||
verbose_name=_("Gebucht am"))
|
verbose_name=_("Gebucht am"))
|
||||||
comment = models.CharField(
|
comment = models.CharField(
|
||||||
max_length=512,
|
max_length=512,
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
<td> {{item.id_bird}} </td>
|
<td> {{item.id_bird}} </td>
|
||||||
<td> {{item.costs}} </td>
|
<td> {{item.costs}} </td>
|
||||||
<td> {{item.created}} </td>
|
<td> {{item.created}} </td>
|
||||||
<td> {{item.comment}} </td>
|
<td> {{item.comment|default_if_none:""}} </td>
|
||||||
<td> {{item.user}} </td>
|
<td> {{item.user}} </td>
|
||||||
<td><a href="{% url 'costs_edit' item.id %}"><i class="fa-sharp fa-solid fa-pen"></i></a></td>
|
<td><a href="{% url 'costs_edit' item.id %}"><i class="fa-sharp fa-solid fa-pen"></i></a></td>
|
||||||
<td><a href="{% url 'costs_delete' item.id %}"><i class="fa-sharp fa-solid fa-trash"></i></a></td>
|
<td><a href="{% url 'costs_delete' item.id %}"><i class="fa-sharp fa-solid fa-trash"></i></a></td>
|
||||||
|
|
41
app/costs/templates/costs/costs_create.html
Normal file
41
app/costs/templates/costs/costs_create.html
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<h3>Buchung anlegen</h3>
|
||||||
|
<p></p>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-5 mb-3">
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<fieldset>
|
||||||
|
{% csrf_token %}
|
||||||
|
{{form|crispy}}
|
||||||
|
<button class="btn btn-success" type="abbort">Abbrechen</button>
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-lg-5">
|
||||||
|
<h4>
|
||||||
|
Kennung
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
|
||||||
|
Reiciendis, hic enim pariatur, exercitationem, repellat quasi sit
|
||||||
|
temporibus dicta voluptate in voluptates. Alias deserunt sint
|
||||||
|
suscipit explicabo et. Perferendis, dolor praesentium.
|
||||||
|
</p>
|
||||||
|
<h4>
|
||||||
|
Vogel
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
|
||||||
|
Reiciendis, hic enim pariatur, exercitationem, repellat quasi sit
|
||||||
|
temporibus dicta voluptate in voluptates. Alias deserunt sint
|
||||||
|
suscipit explicabo et. Perferendis, dolor praesentium.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
|
@ -49,7 +49,4 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{% static 'js/bird.js' %}"></script>
|
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
|
@ -38,7 +38,4 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{% static 'js/bird.js' %}"></script>
|
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
|
@ -3,6 +3,7 @@ from django.shortcuts import render, redirect
|
||||||
from .models import Costs
|
from .models import Costs
|
||||||
from .forms import CostsForm
|
from .forms import CostsForm
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def costs_all(request):
|
def costs_all(request):
|
||||||
costs = Costs.objects.all()
|
costs = Costs.objects.all()
|
||||||
|
@ -10,6 +11,20 @@ def costs_all(request):
|
||||||
return render(request, "costs/costs_all.html", context)
|
return render(request, "costs/costs_all.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url="account_login")
|
||||||
|
def costs_create(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
form = CostsForm(request.POST or None)
|
||||||
|
if form.is_valid():
|
||||||
|
fs = form.save(commit=False)
|
||||||
|
fs.user = request.user
|
||||||
|
fs.save()
|
||||||
|
return redirect("costs_all")
|
||||||
|
form = CostsForm()
|
||||||
|
context = {"form": form}
|
||||||
|
return render(request, "costs/costs_create.html", context)
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def costs_edit(request, id):
|
def costs_edit(request, id):
|
||||||
costs = Costs.objects.get(id=id)
|
costs = Costs.objects.get(id=id)
|
||||||
|
@ -22,23 +37,12 @@ def costs_edit(request, id):
|
||||||
context = {"costs": costs, "form": form}
|
context = {"costs": costs, "form": form}
|
||||||
return render(request, "costs/costs_edit.html", context)
|
return render(request, "costs/costs_edit.html", context)
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def costs_delete(request, id):
|
def costs_delete(request, id):
|
||||||
costs = Costs.objects.get(id=id)
|
costs = Costs.objects.get(id=id)
|
||||||
form = CostsForm(request.POST or None, instance=costs)
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
costs.delete()
|
costs.delete()
|
||||||
return redirect("costs_all")
|
return redirect("costs_all")
|
||||||
context = {"costs": costs}
|
context = {"costs": costs}
|
||||||
return render(request, "costs/costs_delete.html", context)
|
return render(request, "costs/costs_delete.html", context)
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
|
||||||
def costs_create(request):
|
|
||||||
form = CostsForm()
|
|
||||||
if request.method == "POST":
|
|
||||||
form = CostsForm(request.POST or None)
|
|
||||||
if form.is_valid():
|
|
||||||
fs = form.save(commit=False)
|
|
||||||
fs.user = request.user
|
|
||||||
fs.save()
|
|
||||||
return render(request, "costs/costs_all.html")
|
|
Loading…
Add table
Add a link
Reference in a new issue