Skip to content
Snippets Groups Projects
Commit df9bce3f authored by Frank Poetzsch-Heffter's avatar Frank Poetzsch-Heffter
Browse files

tables and forms dont tolerate each other

parent 2d12b2a1
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ class BookingForm(forms.ModelForm):
class CheckBookingForm(forms.ModelForm):
accounts = Account.objects.filter().order_by('costcenter', 'name')
account = forms.ModelChoiceField(queryset=accounts, label='Buchungskonto')
account = forms.ModelChoiceField(required=False, queryset=accounts, label='Buchungskonto')
class Meta:
model = Account
......
from django.db import models
from django.contrib.auth.models import User
from datetime import date
# TODO: Make dynamic
YEARLIST = [(2020, '2020'),
......@@ -19,8 +20,8 @@ class Status:
status_list = [
Status(name='beantragt', style_class='red'),
Status(name='bewilligt', style_class='orange'),
Status(name='abgelehnt', style_class='black'),
Status(name='bewilligt', style_class='orange'),
Status(name='bestellt', style_class='darkyellow'),
Status(name='eingereicht', style_class='blue'),
Status(name='bezahlt', style_class='green'),
......@@ -65,17 +66,17 @@ class Booking(models.Model):
account = models.ForeignKey(to=Account, on_delete=models.SET_NULL, blank=True, null=True)
contact = models.ForeignKey(to=User, related_name='bookings', on_delete=models.SET_NULL
, verbose_name="Erstellt von", blank=True, null=True)
invoice_date = models.DateField(default='2000-12-31')
invoice_date = models.DateField(default=date.today)
invoice_number = models.CharField(max_length=20, default='0')
firma = models.CharField(max_length=30, default='')
description = models.CharField(max_length=50)
amount = models.DecimalField(max_digits=9, decimal_places=2, default=0.00)
planned_amount = models.IntegerField()
submission_date = models.DateField(default='2000-12-31')
submission_date = models.DateField(default=date.today)
justification = models.CharField(max_length=2000, blank=True, null=True)
payout_number = models.IntegerField(default=0)
booking_date = models.DateField(default='2000-12-31')
maturity = models.DateField(default='2000-12-31')
booking_date = models.DateField(default=date.today)
maturity = models.DateField(default=date.today)
upload = models.FileField(upload_to='uploads/fibu/%Y/', default=None, blank=True, null=True)
status = models.IntegerField(default=0, choices=status_choices, verbose_name="Status")
......
......@@ -3,52 +3,78 @@
<main>
{# <a href="{% url 'fibu_make_booking' %}" class="waves-effect waves-light btn green">Neuen Antrag stellen</a>#}
<a class="waves-effect waves-light btn green modal-trigger right" href="#new-modal">
<i class="material-icons left">add</i> Buchungskonto anlegen
</a>
{% block content %}
<h4>Buchungskonten</h4>
<h4>Neues Buchungskonto</h4>
<form method="POST" style="border-width: 5px; background: #eee;">
{% csrf_token %}
{% form form=form %}
{% endform %}
<button type="submit" class="waves-effect waves-light btn green right">
<i class="material-icons left">send</i> Buchungskonto anlegen
</button>
{% if form.errors %}
<script>
var onFinish = function () {
$("#new-modal").modal("open");
};
</script>
{% endif %}
<form method="POST">
<div id="new-modal" class="modal">
<div class="modal-content">
<h5>Neues Buchungskonto anlegen</h5>
{% csrf_token %}
{% form form=form %}
{% endform %}
</div>
<div class="modal-footer">
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">save</i> Buchungskonto anlegen
</button>
</div>
</div>
</form>
<h4>Bestehende Buchungskonten</h4>
<div class="collection">
{% for account in accounts %}
<div class="collection-item row">
<span class="col s6 m6">{{ account.name }}</span>
<span class="col s2 m2">{{ account.costcenter }}</span>
{% if account.income %}
<span class="col s1 m1 right-align">{{ account.budget }}</span>
<span class="col s1 m1 right-align"></span>
{% else %}
<span class="col s2 m2 right-align">{{ account.budget }}</span>
{% endif %}
<span class="col s2 m2 right-align">
<form action="{% url 'account_edit' account.id %}" class="left">
{% csrf_token %}
<table>
<thead>
<tr>
<th>Buchungskonto</th>
<th>Kostenstelle</th>
<th>erwartete Einnahmen</th>
<th>erwartete Ausgaben</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for account in accounts %}
<tr>
<td>{{ account.name }}</td>
<td>{{ account.costcenter }}</td>
{% if account.income %}
<td>{{ account.budget }}</td>
<td></td>
{% else %}
<td></td>
<td>{{ account.budget }}</td>
{% endif %}
<td class="right-align">
<form action="{% url 'account_edit' account.id %}" class="left">
{% csrf_token %}
<input type="hidden" value="{{ account.id }}" name="account-id">
<button type="submit" name="edit"
class="waves-effect waves-light btn-flat btn-flat-medium" title="Bearbeiten">
<i class="material-icons center green-text">create</i>
</button>
</form>
<form action="" method="POST" class="left">
{% csrf_token %}
<input type="hidden" value="{{ account.id }}" name="account-id">
<button type="submit" name="edit"
class="waves-effect waves-light btn-flat btn-flat-medium" title="Bearbeiten">
<i class="material-icons center green-text">create</i>
<button type="submit" onclick="return confirm('Wollen Sie das Buchungskonto wirklich löschen?')" name="cancel" class="waves-effect waves-light btn-flat btn-flat-medium" title="Löschen">
<i class="material-icons center red-text">cancel</i>
</button>
</form>
<form action="" method="POST" class="left">
{% csrf_token %}
<input type="hidden" value="{{ account.id }}" name="account-id">
<button type="submit" onclick="return confirm('Wollen Sie das Buchungskonto wirklich löschen?')" name="cancel" class="waves-effect waves-light btn-flat btn-flat-medium" title="Löschen">
<i class="material-icons center red-text">cancel</i>
</button>
</form>
</span>
</div>
{% endfor %}
</div>
{% endblock %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</main>
{% include 'partials/footer.html' %}
......@@ -3,59 +3,42 @@
<main>
<h4>Anträge prüfen</h4>
<table>
<thead>
<tr>
<th>Antragsteller</th>
<th>Anschaffungswunsch</th>
<th>Geplante Kosten</th>
<th>Buchungskonto</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% if not filter.qs %}
<tr>
<td colspan="5" class="flow-text center-align">
Keine offenen Anträge vorhanden
</td>
</tr>
{% endif %}
{% if not filter.qs %}
<span class="flow-text center-align">
Keine offenen Anträge vorhanden
</span>
{% else %}
<div class="collection-item row grey white-text">
<span class="col s2">Antragsteller</span>
<span class="col s3">Anschaffungswunsch</span>
<span class="col s2 right-align">Geplante Kosten</span>
<span class="col s3">Buchungskonto</span>
<span class="col s2">Aktionen</span>
</div>
{% for booking in filter.qs %}
<tr>
<form method="POST" action="">
<div class="collection-item row">
<form method="POST">
{% csrf_token %}
<input type="hidden" value="{{ booking.id }}" name="booking-id">
{% if booking.status < 2 %}
<td>{{ booking.contact }}</td>
<td>{{ booking.description }}</td>
<td>{{ booking.planned_amount }} €</td>
<td>{{ form.account }}</td>
{% endif %}
<td>
{% if booking.status < 2 %}
<button type="submit" name="allow"
class="waves-effect waves-light btn-flat btn-flat-medium" title="Annehmen">
<i class="material-icons center green-text">check_circle</i>
</button>
{% endif %}
{% if booking.status < 3 %}
<button type="submit" name="deny" value="Blubb"
class="waves-effect waves-light btn-flat btn-flat-medium" title="Ablehnen">
<i class="material-icons center red-text">not_interested</i>
</button>
</td>
{% endif %}
<span class="col s2">{{ booking.contact.get_full_name }}</span>
<span class="col s3">{{ booking.description }}</span>
<span class="col s2 right-align">{{ booking.planned_amount }} €</span>
<span class="col s3">{{ form.account }}</span>
<span class="col s2">
<button type="submit" name="allow"
class="waves-effect waves-light btn-flat btn-flat-medium" title="Annehmen">
<i class="material-icons center green-text">check_circle</i>
</button>
<button type="submit" name="deny"
class="waves-effect waves-light btn-flat btn-flat-medium" title="Ablehnen">
<i class="material-icons center red-text">not_interested</i>
</button>
</span>
</form>
</tr>
</div>
{% endfor %}
</tbody>
</table>
{% endif %}
</main>
{% include 'partials/footer.html' %}
......@@ -18,7 +18,8 @@
<thead>
<tr>
<th>Anschaffungswunsch</th>
<th>Geplanter Betrag</th>
<th class="right-align">Geplanter Betrag</th>
<th>Kostenstelle</th>
<th>Antragsteller</th>
<th>Status</th>
<th>Aktionen</th>
......@@ -29,7 +30,7 @@
<td>
<a href="{% url "booking_book" booking.id %}">{{ booking.description }}</a>
</td>
<td>{{ booking.planned_amount }} €</td>
<td class="right-align">{{ booking.planned_amount }} €</td>
<td>{{ booking.account|default:"" }}</td>
<td>{{ booking.contact.get_full_name }}</td>
<td>
......@@ -38,8 +39,14 @@
</span>
</td>
<td>
<span class="left">
<a class="waves-effect waves-light btn-flat btn-flat-medium green-text" title="Bearbeiten"
href="{% url "booking_book" booking.id %}">
<i class="material-icons">edit</i>
</a>
</span>
{% if booking.status < 2 %}
<form method="POST" class="right">
<form method="POST" class="left">
{% csrf_token %}
<input type="hidden" value="{{ booking.id }}" name="booking-id">
<button type="submit"
......@@ -50,10 +57,6 @@
</button>
</form>
{% endif %}
<a class="waves-effect waves-light btn-flat btn-flat-medium green-text right" title="Bearbeiten"
href="{% url "booking_book" booking.id %}">
<i class="material-icons">edit</i>
</a>
</td>
</tr>
{% endfor %}
......
......@@ -45,7 +45,7 @@
</div>
<span class="col s12 m3">
{# Delete #}
{% if booking.status == 0 or booking.status == 1 %}
{% if booking.status < 3 %}
<form action="" method="POST" class="right">
{% csrf_token %}
<input type="hidden" value="{{ booking.id }}" name="booking-id">
......@@ -77,7 +77,7 @@
<input type="hidden" value="{{ booking.status }}" name="booking-status">
{% if booking.status == 1 %}
{% if booking.status == 2 %}
<button type="submit" name="ordered"
class="waves-effect waves-light btn-flat btn-flat-medium left"
title="Status auf 'bestellt' ändern">
......
......@@ -78,22 +78,19 @@ def check(request):
if request.method == 'POST':
if 'booking-id' in request.POST:
booking_id = request.POST['booking-id']
if 'allow' in request.POST:
if "account" in request.POST:
account = request.POST['account']
print('account:', account)
Booking.objects.filter(id=booking_id).update(status=1, account=account)
messages.success(request, "Der Antrag wurde erfolgreich angenommen.")
Booking.objects.filter(id=booking_id).update(status=2, account=account)
messages.success(request, "Der Antrag wurde angenommen.")
else:
messages.error(request, "Bitte wähle eine Kostenstelle aus, um den Antrag anzunehmen.")
messages.error(request, "Bitte wähle ein Buchungskonto aus, um den Antrag anzunehmen.")
elif 'deny' in request.POST:
Booking.objects.filter(id=booking_id).update(status=2)
messages.success(request, "Der Antrag wurde erfolgreich abgelehnt.")
Booking.objects.filter(id=booking_id).update(status=1)
messages.success(request, "Der Antrag wurde abgelehnt.")
booking_list = Booking.objects.filter(status=0).order_by('submission_date')
bookings = BookingFilter(request.GET, queryset=booking_list)
form = CheckBookingForm()
return render(request, 'fibu/booking/check.html', {'filter': bookings, 'form': form})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment