Skip to content
Snippets Groups Projects
Commit 1643a64a authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

- Update table for checking of requests

- Redesign booking edit page
-
parent a118c55a
No related branches found
No related tags found
No related merge requests found
......@@ -3,17 +3,28 @@
<main>
<h4>Anträge prüfen</h4>
{% for booking in filter.qs %}
<table>
<thead>
<table>
<thead>
<tr>
<th>Antragsteller</th>
<th>Anschaffungswunsch</th>
<th>Geplante Kosten</th>
<th>Zugeordnete Kostenstelle</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% if not filter.qs %}
<tr>
<th>Antragsteller</th>
<th>Anschaffungswunsch</th>
<th>Geplante Kosten</th>
<th>Zugeordnete Kostenstelle</th>
<th>Aktionen</th>
<td colspan="5" class="flow-text center-align">
Keine offenen Anträge vorhanden
</td>
</tr>
</thead>
{% endif %}
{% for booking in filter.qs %}
<tr>
<form method="POST">
{% csrf_token %}
......@@ -40,8 +51,9 @@
{% endif %}
</form>
</tr>
</table>
{% endfor %}
{% endfor %}
</tbody>
</table>
</main>
{% include 'partials/footer.html' %}
......@@ -2,24 +2,23 @@
{% load material_form %}
<main>
<h4>Antrag bearbeiten</h4>
<h4>Beschaffung</h4>
<form method="POST" style="background: #eee">
<form method="POST" action="">
{% csrf_token %}
{% form form=form %}
{% part form.planned_amount prefix %}<i class="material-icons prefix">euro_symbol</i>{% endpart %}
{% endform %}
<span class="right">
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Änderungen übernehmen
</button>
<a href="{% url 'fibu_index' %}">
<button type="button" class="waves-effect waves-light btn grey">
<i class="material-icons left">cancel</i> Abbrechen
</button>
</span>
</a>
</form>
<div class="right">
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">save</i> Änderungen übernehmen
</button>
<a href="{% url 'fibu_index' %}" class="waves-effect waves-light btn red">
<i class="material-icons left">cancel</i> Abbrechen
</a>
</div>
</form>
</main>
{% include 'partials/footer.html' %}
......@@ -5,7 +5,7 @@
<a class="waves-effect waves-light btn green modal-trigger right" href="#new-modal">
<i class="material-icons left">add</i> Antrag stellen
</a>
<h4>Anträge von {{ user.get_fullname }}</h4>
<h4>Meine Anträge</h4>
{% if form.errors %}
......
......@@ -58,15 +58,18 @@ def index(request):
def edit(request, id):
booking = get_object_or_404(Booking, id=id)
form = BookingForm(instance=booking)
template = 'fibu/booking/edit.html'
if request.method == 'POST':
form = BookingForm(request.POST, instance=booking)
if form.is_valid():
form.save()
messages.success(request, "Die Änderungen am Antrag wurden erfolgreich übernommen.")
return redirect(reverse('fibu_index'))
context = {'form': form}
return render(request, template, context)
return render(request, 'fibu/booking/edit.html', context)
@login_required
......@@ -75,17 +78,22 @@ def check(request):
if request.method == 'POST':
if 'booking-id' in request.POST:
booking_id = request.POST['booking-id']
# booking = Booking.objects.get(id=booking_id)
if 'allow' in request.POST:
Booking.objects.filter(id=booking_id).update(status=1)
account = request.POST['account']
print('account:', account)
Booking.objects.filter(id=booking_id).update(account=account)
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.")
else:
messages.error(request, "Bitte wähle eine Kostenstelle 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_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