diff --git a/schoolapps/aub/migrations/0003_auto_20180410_2343.py b/schoolapps/aub/migrations/0003_auto_20180410_2343.py new file mode 100644 index 0000000000000000000000000000000000000000..152fc162a92953eee158a13eb2453c16758d63c8 --- /dev/null +++ b/schoolapps/aub/migrations/0003_auto_20180410_2343.py @@ -0,0 +1,17 @@ +# Generated by Django 2.0.4 on 2018-04-10 21:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('aub', '0002_aub_status'), + ] + + operations = [ + migrations.AlterModelOptions( + name='aub', + options={'permissions': (('apply_for_aub', 'Apply for a AUB'), ('cancel_aub', 'Cancel a AUB'), ('allow1_aub', 'First permission'), ('allow2_aub', 'Second permission'), ('check_aub', 'Check a AUB'))}, + ), + ] diff --git a/schoolapps/aub/migrations/0004_auto_20180411_0007.py b/schoolapps/aub/migrations/0004_auto_20180411_0007.py new file mode 100644 index 0000000000000000000000000000000000000000..f2c8eb6aca3ccd5bf1a38951d0db11875812706f --- /dev/null +++ b/schoolapps/aub/migrations/0004_auto_20180411_0007.py @@ -0,0 +1,17 @@ +# Generated by Django 2.0.4 on 2018-04-10 22:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('aub', '0003_auto_20180410_2343'), + ] + + operations = [ + migrations.AlterModelOptions( + name='aub', + options={'permissions': (('apply_for_aub', 'Apply for a AUB'), ('cancel_aub', 'Cancel a AUB'), ('allow1_aub', 'First permission'), ('allow2_aub', 'Second permission'), ('check1_aub', 'Check a AUB'), ('check2_aub', 'Check a AUB'))}, + ), + ] diff --git a/schoolapps/aub/models.py b/schoolapps/aub/models.py index 2c6cf5206e465574ba7aefcfe9f04603279a3d8d..e9f33f9ce7e44b08acce6b01781637cb32e964c9 100644 --- a/schoolapps/aub/models.py +++ b/schoolapps/aub/models.py @@ -53,6 +53,9 @@ class Aub(models.Model): class Meta: permissions = ( ('apply_for_aub', 'Apply for a AUB'), - ('allow_aub', 'Allow a AUB'), - ('check_aub', 'Check a AUB') + ('cancel_aub', 'Cancel a AUB'), + ('allow1_aub', 'First permission'), + ('allow2_aub', 'Second permission'), + ('check1_aub', 'Check a AUB'), + ('check2_aub', 'Check a AUB') ) diff --git a/schoolapps/aub/templates/aub/check1.html b/schoolapps/aub/templates/aub/check1.html new file mode 100644 index 0000000000000000000000000000000000000000..7a5d674f6e6dfec16c0536e49188c84aa72b6236 --- /dev/null +++ b/schoolapps/aub/templates/aub/check1.html @@ -0,0 +1,38 @@ +{% include 'partials/header.html' %} + +<main> + <h5>Ausstehende Anträge</h5> + + + <ul class="collection"> + {% for aub in aubs %} + <li class="collection-item"> + <div class="row"> + <div class="col s12 m8"> + <p class="title"> + <i class="material-icons left">access_time</i> + {{ aub.from_dt }} bis {{ aub.to_dt }} + </p> + <p><a href="{% url 'aub_details' aub.id %}">{{ aub.description }}</a></p> + </div> + <div class="col s12 m4"> + <p> + <form action="" method="POST" class="right"> + {% csrf_token %} + <input type="hidden" value="{{ aub.id }}" name="aub-id"> + <button type="submit" name="semi-allow" class="waves-effect waves-light btn-flat btn-flat-large"> + <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-large"> + <i class="material-icons center red-text">cancel</i> + </button> + </form> + </p> + </div> + </div> + </li> + {% endfor %} + </ul> +</main> + +{% include 'partials/footer.html' %} diff --git a/schoolapps/aub/templates/aub/check.html b/schoolapps/aub/templates/aub/check2.html similarity index 100% rename from schoolapps/aub/templates/aub/check.html rename to schoolapps/aub/templates/aub/check2.html diff --git a/schoolapps/aub/urls.py b/schoolapps/aub/urls.py index 4a0af38a83192b69ab8b58c16d92fc6499e70390..6d17c2d0edc1c0d1353f57235770cd26136e1cab 100644 --- a/schoolapps/aub/urls.py +++ b/schoolapps/aub/urls.py @@ -7,5 +7,6 @@ urlpatterns = [ path('details/<int:aub_id>/', views.details, name='aub_details'), path('apply_for', views.apply_for, name='aub_apply_for'), path('applied_for', views.applied_for, name='aub_applied_for'), - path('check', views.check, name='aub_check'), + path('check1', views.check1, name='aub_check1'), + path('check2', views.check2, name='aub_check2'), ] diff --git a/schoolapps/aub/views.py b/schoolapps/aub/views.py index ca246a9ff547237d6b28d76af3f3e0a82d046000..67c8659c8f56220d554a4d34b6da2bfb1975dc07 100644 --- a/schoolapps/aub/views.py +++ b/schoolapps/aub/views.py @@ -6,7 +6,10 @@ from django.utils import timezone from .forms import ApplyForAUBForm from .models import Aub, Status +from itertools import chain + IN_PROCESSING_STATUS = Status.objects.get_or_create(name='In Bearbeitung', style_classes='orange')[0] +SEMI_ALLOWED_STATUS = Status.objects.get_or_create(name='In Bearbeitung', style_classes='yellow')[0] ALLOWED_STATUS = Status.objects.get_or_create(name='Genehmigt', style_classes='green')[0] NOT_ALLOWED_STATUS = Status.objects.get_or_create(name='Abgelehnt', style_classes='red')[0] @@ -68,8 +71,26 @@ def applied_for(request): return render(request, 'aub/applied_for.html', context) @login_required -@permission_required('aub.check_aub') -def check(request): +@permission_required('aub.check1_aub') +def check1(request): + if request.method == 'POST': + if 'aub-id' in request.POST: + aub_id = request.POST['aub-id'] + if 'semi-allow' in request.POST: + Aub.objects.filter(id=aub_id).update(status=SEMI_ALLOWED_STATUS) + elif 'deny' in request.POST: + Aub.objects.filter(id=aub_id).update(status=NOT_ALLOWED_STATUS) + + aubs = Aub.objects.filter(status=IN_PROCESSING_STATUS) + context = { + 'aubs': aubs + } + + return render(request, 'aub/check1.html', context) + +@login_required +@permission_required('aub.check2_aub') +def check2(request): if request.method == 'POST': if 'aub-id' in request.POST: aub_id = request.POST['aub-id'] @@ -78,8 +99,9 @@ def check(request): elif 'deny' in request.POST: Aub.objects.filter(id=aub_id).update(status=NOT_ALLOWED_STATUS) - aubs = Aub.objects.filter(status=IN_PROCESSING_STATUS) + aubs = Aub.objects.filter(status=SEMI_ALLOWED_STATUS) context = { 'aubs': aubs } - return render(request, 'aub/check.html', context) + + return render(request, 'aub/check2.html', context) diff --git a/schoolapps/templates/partials/header.html b/schoolapps/templates/partials/header.html index 1a5474e35cfcb438c72f599a3e417345f68466cd..20334537c49be175852153840c18294b5bbb66a6 100644 --- a/schoolapps/templates/partials/header.html +++ b/schoolapps/templates/partials/header.html @@ -105,7 +105,8 @@ </li> <li><a class="subheader">Lehrerfunktionen</a></li> <li><a href="{% url 'aub_index' %}">Antrag auf Unterrichtsbefreiung</a></li> - <li><a href="{% url 'aub_check' %}">Anträge genehmigen</a></li> + <li><a href="{% url 'aub_check1' %}">Anträge genehmigen 1</a></li> + <li><a href="{% url 'aub_check2' %}">Anträge genehmigen 2</a></li> <li> <div class="divider"></div> </li>