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

edit template - add justification

parent 1165b891
No related branches found
No related tags found
No related merge requests found
...@@ -45,13 +45,16 @@ from .models import Booking, CostCenter ...@@ -45,13 +45,16 @@ from .models import Booking, CostCenter
# fields = ('cost_center', 'description', 'planned_amount') # fields = ('cost_center', 'description', 'planned_amount')
class MakeBookingForm(forms.ModelForm): class EditBookingForm(forms.ModelForm):
description = forms.CharField(label='Was soll gekauft werden?') description = forms.CharField(label='Was soll gekauft werden?')
planned_amount = forms.IntegerField(label='Welcher Betrag ist dafür erforderlich (Euro)?') planned_amount = forms.IntegerField(label='Welcher Betrag ist dafür erforderlich (Euro)?')
justification = forms.CharField(label='Begründe ggf. deinen Antrag.', required=False)
layout = Layout(Row(Fieldset('Beschreibung', 'description'), Fieldset('Erwarteter Betrag', 'planned_amount'))) layout = Layout(Row(Fieldset('Beschreibung', 'description'),
Fieldset('Erwarteter Betrag', 'planned_amount')),
Row(Fieldset('Begründung (optional)', 'justification')))
class Meta: class Meta:
model = Booking model = Booking
fields = ('id', 'description', 'planned_amount') fields = ('id', 'description', 'planned_amount', 'justification')
...@@ -51,6 +51,7 @@ class Booking(models.Model): ...@@ -51,6 +51,7 @@ class Booking(models.Model):
# amount = models.DecimalField(max_digits=10, decimal_places=2) # amount = models.DecimalField(max_digits=10, decimal_places=2)
planned_amount = models.IntegerField() planned_amount = models.IntegerField()
submission_date = models.DateField(default='2019-01-01') submission_date = models.DateField(default='2019-01-01')
justification = models.CharField(max_length=2000, blank=True, null=True)
# payout_number = models.IntegerField() # payout_number = models.IntegerField()
# booking_date = models.DateField() # booking_date = models.DateField()
# maturity = models.DateField() # maturity = models.DateField()
......
...@@ -10,8 +10,13 @@ ...@@ -10,8 +10,13 @@
{% form form=form %} {% form form=form %}
{% endform %} {% endform %}
<button type="submit" class="waves-effect waves-light btn green"> <button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Antrag stellen <i class="material-icons left">send</i> Änderungen übernehmen
</button> </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>
</a>
</form> </form>
</main> </main>
......
...@@ -18,24 +18,23 @@ ...@@ -18,24 +18,23 @@
</form> </form>
<h5>Laufende Anträge</h5> <h5>Laufende Anträge</h5>
<table class="highlight"> <div class="collection">
<thead> {% for booking in bookings %}
<tr> {# <div class="collection-item row">#}
<th>Beschreibung</th> <a href="{% url 'booking_edit' booking.id %}" class="collection-item row">
<th class="flushright">Erwarteter Betrag</th> <span class="col s12 m8">{{ booking.description }}</span>
<th>Status</th> <span class="col s12 m3 flushright">{{ booking.planned_amount }} €</span>
</tr> <span class="col s12 m1 badge new {{ booking.getStatus.style_class }}">{{ booking.getStatus.name }}</span>
</thead> {# <form action="{% url 'booking_edit' booking.id %}" class="col s12 m2">#}
<tbody> {# {% csrf_token %}#}
{% for item in bookings %} {# <button type="submit" name="edit" class="waves-effect waves-light btn-flat btn-flat-medium" title="Bearbeiten">#}
<tr> {# <i class="material-icons center green-text">create</i>#}
<td>{{ item.description }}</td> {# </button>#}
<td class="flushright">{{ item.planned_amount }} €</td> {# </form>#}
<td><span class="badge new {{ item.getStatus.style_class }}">{{ item.getStatus.name }}</span></td> </a>
</tr> {# </div>#}
{% endfor %} {% endfor %}
</tbody> </div>
</table>
{% endblock %} {% endblock %}
</main> </main>
{% include 'partials/footer.html' %} {% include 'partials/footer.html' %}
...@@ -7,6 +7,7 @@ urlpatterns = [ ...@@ -7,6 +7,7 @@ urlpatterns = [
path('check', views.check, name='booking_check'), path('check', views.check, name='booking_check'),
path('check', views.check, name='booking_check1'), path('check', views.check, name='booking_check1'),
path('check', views.check, name='booking_check2'), path('check', views.check, name='booking_check2'),
path('edit/<int:id>', views.edit, name='booking_edit'),
# path('make_booking', views.make_booking, name='fibu_make_booking'), # path('make_booking', views.make_booking, name='fibu_make_booking'),
# path('edit/<int:id>', views.edit, name='booking_edit'), # path('edit/<int:id>', views.edit, name='booking_edit'),
] ]
from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.decorators import login_required, permission_required
from django.urls import reverse
from django.shortcuts import render, redirect, get_object_or_404 from django.shortcuts import render, redirect, get_object_or_404
from .models import Booking from .models import Booking
from .filters import BookingFilter from .filters import BookingFilter
from .forms import MakeBookingForm from .forms import EditBookingForm
@login_required @login_required
#@permission_required('fibu.view_booking') #@permission_required('fibu.view_booking')
def index(request): def index(request):
items = Booking.objects.filter() bookings = Booking.objects.filter()
print(items) print(bookings)
# @login_required # @login_required
# @permission_required('fibu.make_booking') # @permission_required('fibu.make_booking')
...@@ -18,16 +19,17 @@ def index(request): ...@@ -18,16 +19,17 @@ def index(request):
if 'booking-id' in request.POST: if 'booking-id' in request.POST:
booking_id = request.POST['booking-id'] booking_id = request.POST['booking-id']
booking = Booking.objects.get(id=booking_id) booking = Booking.objects.get(id=booking_id)
form = MakeBookingForm(instance=booking) form = EditBookingForm(instance=booking)
print('Edit-Form erstellt ############# form.is_valid:', form.is_valid()) print('Edit-Form erstellt ############# form.is_valid:', form.is_valid())
else: else:
form = MakeBookingForm(request.POST or None) form = EditBookingForm(request.POST or None)
else: else:
form = MakeBookingForm() form = EditBookingForm()
if form.is_valid(): if form.is_valid():
description = form.cleaned_data['description'] description = form.cleaned_data['description']
planned_amount = form.cleaned_data['planned_amount'] planned_amount = form.cleaned_data['planned_amount']
booking = Booking(description=description, planned_amount=planned_amount, contact=request.user) justification = form.cleaned_data['justification']
booking = Booking(description=description, planned_amount=planned_amount, contact=request.user, justification=justification)
booking.save() booking.save()
# a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung gestellt", # a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung gestellt",
...@@ -37,10 +39,30 @@ def index(request): ...@@ -37,10 +39,30 @@ def index(request):
# a.save() # a.save()
# return redirect('fibu_make_booking') # return redirect('fibu_make_booking')
return redirect('fibu_index') return redirect('fibu_index')
context = {'bookings': items, 'form': form} context = {'bookings': bookings, 'form': form}
return render(request, 'fibu/index.html', context) return render(request, 'fibu/index.html', context)
@login_required
# @permission_required('aub.apply_for_aub')
def edit(request, id):
booking = get_object_or_404(Booking, id=id)
form = EditBookingForm(instance=booking)
template = 'fibu/edit.html'
if request.method == 'POST':
form = EditBookingForm(request.POST, instance=booking)
if form.is_valid():
form.save()
# a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung verändert",
# description="Sie haben Ihren Antrag auf Unterrichtsbefreiung " +
# "für den Zeitraum von {} bis {} bearbeitet.".format(
# aub.from_date, aub.to_date), app=AubConfig.verbose_name)
# a.save()
return redirect(reverse('fibu_index'))
context = {'form': form}
return render(request, template, context)
@login_required @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