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

adjust form layout

parent 4e7ef221
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,15 @@ class EditBookingForm(forms.ModelForm):
fields = ('id', 'description', 'planned_amount', 'justification')
class CheckBookingForm(forms.ModelForm):
costcenterlist = Costcenter.objects.filter()
costcenter = forms.ModelChoiceField(queryset=costcenterlist, label='Kostenstelle')
class Meta:
model = Costcenter
fields = ('id', 'name')
class EditCostcenterForm(forms.ModelForm):
name = forms.CharField(max_length=30, label='Kostenstelle')
year = forms.ChoiceField(choices=YEARLIST, label='Jahr')
......@@ -30,13 +39,9 @@ class EditCostcenterForm(forms.ModelForm):
class EditAccountForm(forms.ModelForm):
costcenterlist = Costcenter.objects.filter()
costcenter_choices = [(x, val.name) for x, val in enumerate(costcenterlist)]
# print('choices:', costcenter_choices)
name = forms.CharField(max_length=30, label='Buchungskonto')
costcenterlist = Costcenter.objects.filter()
costcenter = forms.ModelChoiceField(queryset=costcenterlist, label='Kostenstelle')
print('costcenter:', costcenter)
budget = forms.IntegerField(label='Budget')
layout = Layout(Row('name', 'costcenter', 'budget'))
......
......@@ -33,7 +33,7 @@ class Costcenter(models.Model):
name = models.CharField(max_length=20)
year = models.IntegerField(default=2019, choices=YEARLIST, verbose_name="Jahr")
def __str__(self):
return self.name
return "%s" % (self.name)
class Meta:
permissions = (
......
......@@ -5,18 +5,20 @@
<h4>Buchungskonto bearbeiten</h4>
<form method="POST">
<form method="POST" style="background: #eee">
{% csrf_token %}
{% form form=form %}
{% endform %}
<button type="submit" class="waves-effect waves-light btn green">
<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 'account' %}">
<button type="button" class="waves-effect waves-light btn grey">
</button>
<a href="{% url 'account' %}">
<button type="button" class="waves-effect waves-light btn grey">
<i class="material-icons left">cancel</i> Abbrechen
</button>
</a>
</button>
</a>
</span>
</form>
</main>
......
......@@ -4,29 +4,24 @@
<h4>Anträge prüfen</h4>
<div class="collection">
{% for booking in filter.qs %}
<a href="{% url 'booking_edit' booking.id %}" class="collection-item row">
<span class="col s12 m6">{{ booking.description }}</span>
<span class="col s12 m3 flushright">{{ booking.planned_amount }} €</span>
<form action="" method="POST" class="col s12 m2 right">
{% csrf_token %}
<input type="hidden" value="{{ booking.id }}" name="booking-id">
{% if booking.status.id != 2 %}
<span>{{ booking.contact }}</span>
<span>{{ booking.description }}</span>
<span>{{ booking.planned_amount }} €</span>
<form method="POST">
{% csrf_token %}
<input type="hidden" value="{{ booking.id }}" name="booking-id">
{% if booking.status.id != 2 %}
<span>{{ form.costcenter }}</span>
<span>
<button type="submit" name="allow"
class="waves-effect waves-light btn-flat btn-flat-large" title="Annehmen">
<i class="material-icons center green-text">check_circle</i>
</button>
{% endif %}
{% if booking.status.id != 3 %}
<button type="submit" name="deny"
class="waves-effect waves-light btn-flat btn-flat-large" title="Ablehnen">
<i class="material-icons center red-text">not_interested</i>
</button>
{% endif %}
</form>
</a>
class="waves-effect waves-light btn-flat btn-flat-medium" title="Annehmen">
<i class="material-icons center green-text">check_circle</i>
</button>
</span>
{% endif %}
</form>
{% endfor %}
</div>
</main>
{% include 'partials/footer.html' %}
......@@ -5,10 +5,11 @@
<h4>Beschaffung</h4>
<form method="POST">
<form method="POST" style="background: #eee">
{% csrf_token %}
{% form form=form %}
{% endform %}
<span class="right">
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Änderungen übernehmen
</button>
......@@ -16,6 +17,7 @@
<button type="button" class="waves-effect waves-light btn grey">
<i class="material-icons left">cancel</i> Abbrechen
</button>
</span>
</a>
</form>
......
......@@ -5,18 +5,20 @@
<h4>Kostenstelle bearbeiten</h4>
<form method="POST">
<form method="POST" style="background: #eee">
{% csrf_token %}
{% form form=form %}
{% endform %}
<button type="submit" class="waves-effect waves-light btn green">
<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 'costcenter' %}">
<button type="button" class="waves-effect waves-light btn grey">
</button>
<a href="{% url 'costcenter' %}">
<button type="button" class="waves-effect waves-light btn grey">
<i class="material-icons left">cancel</i> Abbrechen
</button>
</a>
</button>
</a>
</span>
</form>
</main>
......
......@@ -4,8 +4,8 @@ from . import views
urlpatterns = [
path('', views.index, name='fibu_index'),
path('check', views.check, name='booking_check'),
path('edit/<int:id>', views.edit, name='booking_edit'),
path('booking/check', views.check, name='booking_check'),
path('booking/edit/<int:id>', views.edit, name='booking_edit'),
path('costcenter', views.costcenter, name='costcenter'),
path('costcenter/edit/<int:id>', views.costcenter_edit, name='costcenter_edit'),
path('account', views.account, name='account'),
......
......@@ -3,7 +3,7 @@ from django.urls import reverse
from django.shortcuts import render, redirect, get_object_or_404
from .models import Booking, Costcenter, Account
from .filters import BookingFilter
from .forms import EditBookingForm, EditCostcenterForm, EditAccountForm
from .forms import EditBookingForm, CheckBookingForm, EditCostcenterForm, EditAccountForm
@login_required
......@@ -58,7 +58,7 @@ def index(request):
def edit(request, id):
booking = get_object_or_404(Booking, id=id)
form = EditBookingForm(instance=booking)
template = 'fibu/edit.html'
template = 'fibu/booking/edit.html'
if request.method == 'POST':
form = EditBookingForm(request.POST, instance=booking)
if form.is_valid():
......@@ -81,7 +81,7 @@ 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)
#booking = Booking.objects.get(id=booking_id)
if 'allow' in request.POST:
Booking.objects.filter(id=booking_id).update(status=1)
elif 'deny' in request.POST:
......@@ -101,7 +101,8 @@ def check(request):
booking_list = Booking.objects.filter(status=0).order_by('submission_date')
bookings = BookingFilter(request.GET, queryset=booking_list)
return render(request, 'fibu/booking/check.html', {'filter': bookings})
form = CheckBookingForm()
return render(request, 'fibu/booking/check.html', {'filter': bookings, 'form': form})
@login_required
......
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