diff --git a/schoolapps/fibu/templates/fibu/booking/check.html b/schoolapps/fibu/templates/fibu/booking/check.html index 4d2fe7e931b4efa24e71c061bb08c689163c7c9d..f6f26b267351679bb567ef72fa2fa64914947fa1 100755 --- a/schoolapps/fibu/templates/fibu/booking/check.html +++ b/schoolapps/fibu/templates/fibu/booking/check.html @@ -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' %} diff --git a/schoolapps/fibu/templates/fibu/booking/edit.html b/schoolapps/fibu/templates/fibu/booking/edit.html index 18c1c344cb601569b2641eb7a440952ef6cc4857..4fabb87a6fc09dbb9c0358efd787a0c611337c1f 100644 --- a/schoolapps/fibu/templates/fibu/booking/edit.html +++ b/schoolapps/fibu/templates/fibu/booking/edit.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' %} diff --git a/schoolapps/fibu/templates/fibu/index.html b/schoolapps/fibu/templates/fibu/index.html index 0adf44018a8429d1ce8067e9d336f885defa4b81..fb4ba3089a3720128e545e46da8493f3c7a73092 100755 --- a/schoolapps/fibu/templates/fibu/index.html +++ b/schoolapps/fibu/templates/fibu/index.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 %} diff --git a/schoolapps/fibu/views.py b/schoolapps/fibu/views.py index e3053c48710857cd216a4f133762f04beacaa45f..b88cc57920bce560b3fe762b61e95afe9420b4fa 100644 --- a/schoolapps/fibu/views.py +++ b/schoolapps/fibu/views.py @@ -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}) diff --git a/schoolapps/templates/partials/header.html b/schoolapps/templates/partials/header.html index aad9165549a13fff250f9ca64cac610238df8ba2..d8c750b82a3b07c7c1bcece3604973c2f8454297 100755 --- a/schoolapps/templates/partials/header.html +++ b/schoolapps/templates/partials/header.html @@ -195,13 +195,14 @@ <ul> {% if perms.fibu.request_booking %} <li class="url-booking_check"> - <a href="{% url 'booking_check' %}"><i class="material-icons">done</i>Anträge + <a href="{% url 'booking_check' %}"><i class="material-icons">done_all</i>Anträge + prüfen </a> </li> {% endif %} {% if perms.fibu.manage_booking %} <li class="url-booking"> - <a href="{% url 'booking' 0 %}"><i class="material-icons">done</i>Buchungen + <a href="{% url 'booking' 0 %}"><i class="material-icons">receipt</i>Buchungen </a> </li> {% endif %} @@ -217,7 +218,7 @@ {% endif %} {% if perms.fibu.manage_booking %} <li class="url-reports url-expenses"> - <a href="{% url 'reports' %}"><i class="material-icons">done</i>Berichte</a> + <a href="{% url 'reports' %}"><i class="material-icons">list</i>Berichte</a> </li> {% endif %} </ul>