diff --git a/schoolapps/aub/filters.py b/schoolapps/aub/filters.py index 5b354ecbfa6b231f7d7915472f475f36f6936561..aa2b9f4a4074a6965e4fac65d9e6ed5ebf1be492 100644 --- a/schoolapps/aub/filters.py +++ b/schoolapps/aub/filters.py @@ -2,13 +2,15 @@ from django import forms import django_filters from .models import Aub + class AUBFilter(django_filters.FilterSet): - #timerangechoices = [('today','Heute'),('thisWeek','Diese Woche'), ('thisMonth','Dieser Monat')] - #timerange = django_filters.ChoiceFilter(label='Zeitumfang', choices=timerangechoices) + # timerangechoices = [('today','Heute'),('thisWeek','Diese Woche'), ('thisMonth','Dieser Monat')] + # timerange = django_filters.ChoiceFilter(label='Zeitumfang', choices=timerangechoices) created_by = django_filters.ChoiceFilter(label='Von') - statuschoices = [('1','In Bearbeitung 1'),('2','In Bearbeitung 2'),('3','Genehmigt'),('4','Abgelehnt')] + statuschoices = [('1', 'In Bearbeitung 1'), ('2', 'In Bearbeitung 2'), ('3', 'Genehmigt'), ('4', 'Abgelehnt')] status = django_filters.ChoiceFilter(label='Status', choices=statuschoices, initial='In Bearbeitung 1') + class Meta: model = Aub - fields = [ 'created_by', 'status'] - ordering = 'status' \ No newline at end of file + fields = ['created_by', 'status'] + ordering = 'status' diff --git a/schoolapps/aub/forms.py b/schoolapps/aub/forms.py index db576133d4ab5a15308d56008d2bb9d439650f87..afd7376c9508a8a4f318ee46a429bfb2d9650727 100755 --- a/schoolapps/aub/forms.py +++ b/schoolapps/aub/forms.py @@ -5,31 +5,39 @@ from datetime import datetime from material import Layout, Row, Fieldset from aub.models import Aub + class FilterAUBForm(forms.Form): - timerangechoices = [('today','Heute'),('thisWeek','Diese Woche'), ('thisMonth','Dieser Monat')] - timerange = forms.ChoiceField(label='Zeitumfang', choices=timerangechoices, initial='thisWeek', widget=forms.RadioSelect) - statuschoices = [('all','Alle'), ('processing','In Bearbeitung'), ('decided','Entschieden')] + timerangechoices = [('today', 'Heute'), ('thisWeek', 'Diese Woche'), ('thisMonth', 'Dieser Monat')] + timerange = forms.ChoiceField(label='Zeitumfang', choices=timerangechoices, initial='thisWeek', + widget=forms.RadioSelect) + statuschoices = [('all', 'Alle'), ('processing', 'In Bearbeitung'), ('decided', 'Entschieden')] status = forms.ChoiceField(label='Status', choices=statuschoices, initial='processing', widget=forms.RadioSelect) - sortingchoices = [('created_at_asc','Nach Datum (neue oben)'),('created_at_desc','Nach Datum (alte oben)'), ('created_by','Nach Antragsteller')] - sorting = forms.ChoiceField(label='Sortierung', choices=sortingchoices, initial='created_at_asc', widget=forms.RadioSelect) + sortingchoices = [('created_at_asc', 'Nach Datum (neue oben)'), ('created_at_desc', 'Nach Datum (alte oben)'), + ('created_by', 'Nach Antragsteller')] + sorting = forms.ChoiceField(label='Sortierung', choices=sortingchoices, initial='created_at_asc', + widget=forms.RadioSelect) layout = Layout(Fieldset('Filter', Row('timerange', 'status', 'sorting'), ) ) + def clean(self): cleaned_data = super().clean() + class ApplyForAUBForm(forms.ModelForm): lessons = [('', ''), ('8:00', '1.'), ('8:45', '2.'), ('9:45', '3.'), ('10:35', '4.'), ('11:35', '5.'), ('12:25', '6.'), ('13:15', '7.'), ('14:05', '8.'), ('14:50', '9.')] initial_from_time = '8:00' initial_to_time = '15:35' from_date = forms.DateField(label='Datum', input_formats=['%d.%m.%Y']) - from_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(this)'})) + from_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, + widget=forms.Select(attrs={'onchange': 'setTime(this)'})) from_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial=initial_from_time, ) to_date = forms.DateField(label='Datum', input_formats=['%d.%m.%Y']) - to_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(this)'})) + to_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, + widget=forms.Select(attrs={'onchange': 'setTime(this)'})) to_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial=initial_to_time) description = forms.CharField(label='Bitte begründen Sie Ihren Antrag.') @@ -76,7 +84,6 @@ class ApplyForAUBForm(forms.ModelForm): return data - # class ApplyForAUBForm(forms.Form): # lessons = [('', ''), ('8:00', '1.'), ('8:45', '2.'), ('9:45', '3.'), ('10:35', '4.'), ('11:35', '5.'), # ('12:25', '6.'), ('13:15', '7.'), ('14:05', '8.'), ('14:50', '9.')] diff --git a/schoolapps/aub/templates/aub/apply_for.html b/schoolapps/aub/templates/aub/apply_for.html index 7781584e02473c74783aa5c1b2de58b2193c1d8b..1baa3d55e8ada3cbd50390acaf902816b794edf0 100755 --- a/schoolapps/aub/templates/aub/apply_for.html +++ b/schoolapps/aub/templates/aub/apply_for.html @@ -3,7 +3,7 @@ <main> - <h5>Antrag auf Unterrichtsbefreiung</h5> + <h4>Antrag auf Unterrichtsbefreiung</h4> <form method = "POST" > {% csrf_token %} diff --git a/schoolapps/aub/templates/aub/check.html b/schoolapps/aub/templates/aub/check.html index 3bba4070641c598729b7ee72d12963c185b4ad35..7f720724573a67f695b774712fb8653f6085fa77 100755 --- a/schoolapps/aub/templates/aub/check.html +++ b/schoolapps/aub/templates/aub/check.html @@ -1,66 +1,68 @@ {% include 'partials/header.html' %} <main> - <form method="GET"> - {{ filter.form.as_p }} - <button type="submit" class="waves-effect waves-light btn blue"> - <i class="material-icons left"></i> Filter aktualisieren - </button> - </form> + <h4>Ausstehende Anträge</h4> - <h5>Ausstehende Anträge</h5> - - <ul class="collection"> -{# {% for aub in aubs %}#} - {% for aub in filter.qs %} -{# {% for aub in aubs %}#} - <li class="collection-item"> - <div class="row"> - <div class="col s12 m4"> - <p class="title"> + <form method="GET"> + {{ filter.form.as_p }} + <button type="submit" class="waves-effect waves-light btn"> + <i class="material-icons left">refresh</i> Filter aktualisieren + </button> + </form> + + <ul class="collection"> + {# {% for aub in aubs %}#} + {% for aub in filter.qs %} + {# {% for aub in aubs %}#} + <li class="collection-item"> + <div class="row"> + <div class="col s12 m4"> + <p class="title"> <span class="item-text"> <i class="material-icons">access_time</i> {# {{ aub.from_dt }} bis {{ aub.to_dt }}#} {{ aub.from_date }} bis {{ aub.to_date }} </span> - </p> - <p><a href="{% url 'aub_details' aub.id %}">{{ aub.description }}</a></p> - </div> - <div class="col s12 m2"> - <p> + </p> + <p><a href="{% url 'aub_details' aub.id %}">{{ aub.description }}</a></p> + </div> + <div class="col s12 m2"> + <p> <span class="item-text"> <i class="material-icons">person</i> {{ aub.created_by }} </span> - </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"> - {% if aub.status_id != 3 %} - <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 aub.status_id != 4 %} - <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> - </p> - </div> - <div class="col s12 m2"> - <p> - <span class="badge new {{ aub.status.style_classes }}">{{ aub.status.name }}</span> - </p> - </div> + </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"> + {% if aub.status_id != 3 %} + <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 aub.status_id != 4 %} + <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> + </p> + </div> + <div class="col s12 m2"> + <p> + <span class="badge new {{ aub.status.style_classes }}">{{ aub.status.name }}</span> + </p> </div> - </li> - {% endfor %} - </ul> + </div> + </li> + {% endfor %} + </ul> </main> {% include 'partials/footer.html' %} diff --git a/schoolapps/aub/templates/aub/details.html b/schoolapps/aub/templates/aub/details.html index 5a41e31ec8c72ea57018a299984b5e91772a080d..cdb152ff2cc4fa99dd6ca1e66a1c0f00122cd4f1 100755 --- a/schoolapps/aub/templates/aub/details.html +++ b/schoolapps/aub/templates/aub/details.html @@ -1,7 +1,6 @@ {% include 'partials/header.html' %} <main> -{# <h5>{{ aub.from_dt }} bis {{ aub.to_dt }}</h5>#} - <h5>{{ aub.from_date }} bis {{ aub.to_date }}</h5> + <h4>{{ aub.from_date }} bis {{ aub.to_date }}</h4> <p><strong>Status: <span class="badge new {{ aub.status.style_classes }}">{{ aub.status.name }}</span></strong></p> <p>{{ aub.description }}</p> <hr> diff --git a/schoolapps/aub/templates/aub/edit.html b/schoolapps/aub/templates/aub/edit.html index 1e0d8c2514f5d7c52fc30e1ee348b9a75e08f820..3b07e767ddc99f428af5eb3268eb30574856880e 100755 --- a/schoolapps/aub/templates/aub/edit.html +++ b/schoolapps/aub/templates/aub/edit.html @@ -3,7 +3,7 @@ <main> - <h5>Antrag auf Unterrichtsbefreiung</h5> + <h4>Antrag auf Unterrichtsbefreiung</h4> <form method = "POST" > {% csrf_token %} @@ -11,7 +11,7 @@ {% form form=form %} {% endform %} <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> Antrag ändern </button> </form> </main> diff --git a/schoolapps/aub/templates/aub/index.html b/schoolapps/aub/templates/aub/index.html index ce70981402874e8855b449b37a6169489ac4634e..0a301f1ea5d0336ad8abc99aed8309adb1e75525 100755 --- a/schoolapps/aub/templates/aub/index.html +++ b/schoolapps/aub/templates/aub/index.html @@ -3,16 +3,19 @@ <main> - <a href="{% url 'aub_apply_for' %}" class="waves-effect waves-light btn green">Neuen Antrag stellen</a> - {% block content %} + {% block content %} - <h5>Übersicht der Anträge</h5> - <ul class="collection"> - {% for aub in aubs %} - <li class="collection-item"> + <h4>Übersicht der Anträge</h4> - <div class="row"> + <a href="{% url 'aub_apply_for' %}" class="waves-effect waves-light btn green">Neuen Antrag stellen</a> + + + <ul class="collection"> + {% for aub in aubs %} + <li class="collection-item"> + + <div class="row"> <div class="col s12 m4"> <p class="title"> <span class="item-text"> @@ -33,21 +36,26 @@ </div> <div class="col s12 m4"> <p> - {% if aub.status_id == 1 %} - <form action="{% url 'aub_edit' aub.id %}" class="right"> - {% csrf_token %} - {# <input type="hidden" value="{{ aub.id }}" name="aub-id">#} - <button type="submit" name="edit" class="waves-effect waves-light btn-flat btn-flat-medium" title="Bearbeiten"> - <i class="material-icons center green-text">create</i> - </button> - </form> - {% endif %} + {% if aub.status_id == 1 %} + <form action="{% url 'aub_edit' aub.id %}" class="right"> + {% csrf_token %} + {# <input type="hidden" value="{{ aub.id }}" name="aub-id">#} + <button type="submit" name="edit" + class="waves-effect waves-light btn-flat btn-flat-medium" + title="Bearbeiten"> + <i class="material-icons center green-text">create</i> + </button> + </form> + {% endif %} {% if aub.status_id == 1 or aub.status_id == 2 %} <form action="" method="POST" class="right"> {% csrf_token %} <input type="hidden" value="{{ aub.id }}" name="aub-id"> - <button type="submit" onclick="return confirm('Wollen Sie den Antrag wirklich löschen?')" name="cancel" class="waves-effect waves-light btn-flat btn-flat-medium" title="Löschen"> + <button type="submit" + onclick="return confirm('Wollen Sie den Antrag wirklich löschen?')" + name="cancel" class="waves-effect waves-light btn-flat btn-flat-medium" + title="Löschen"> <i class="material-icons center red-text">cancel</i> </button> </form> @@ -59,10 +67,10 @@ <p><span class="badge new {{ aub.status.style_classes }}">{{ aub.status.name }}</span></p> </div> </div> - - </li> - {% endfor %} - </ul> + + </li> + {% endfor %} + </ul> {% endblock %} </main> {% include 'partials/footer.html' %} diff --git a/schoolapps/aub/views.py b/schoolapps/aub/views.py index c0fe2e7ae5b7ce9b2c56703ff605be4ab4d63aee..6fb2c3330809fac148c7ac174a3225216eb10aff 100755 --- a/schoolapps/aub/views.py +++ b/schoolapps/aub/views.py @@ -19,6 +19,7 @@ SEMI_ALLOWED_STATUS = Status.objects.get_or_create(name='In Bearbeitung 2', styl 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] + @login_required @permission_required('aub.apply_for_aub') def index(request): @@ -36,7 +37,7 @@ def index(request): instance = Aub.objects.get(id=id) instance.delete() print('Eintrag gelöscht') -# order_crit = '-created_at' + # order_crit = '-created_at' order_crit = 'from_date' aubs = Aub.objects.filter(created_by=request.user).order_by(order_crit)[:100] @@ -45,6 +46,7 @@ def index(request): } return render(request, 'aub/index.html', context) + @login_required @permission_required('aub.apply_for_aub') @check_own_aub(login_url='/index.html') @@ -55,6 +57,7 @@ def details(request, id): } return render(request, 'aub/details.html', context) + @login_required @permission_required('aub.apply_for_aub') def apply_for(request): @@ -67,21 +70,23 @@ def apply_for(request): print('Fall 2 - ', 'form.is_valid:', form.is_valid(), 'form.errors:', form.errors) else: form = ApplyForAUBForm(request.POST or None) - print('Fall 3 - ', 'request.POST:', request.POST, 'form.is_valid:', form.is_valid(), 'form.errors:', form.errors) + print('Fall 3 - ', 'request.POST:', request.POST, 'form.is_valid:', form.is_valid(), 'form.errors:', + form.errors) else: form = ApplyForAUBForm() print('Fall 4 - ', 'form.is_valid:', form.is_valid(), 'form.errors:', form.errors) print('Fall 5 - ', 'form.is_valid:', form.is_valid(), 'form.errors:', form.errors) if form.is_valid(): print('form:', form) - #form.save() + # form.save() from_date = form.cleaned_data['from_date'] from_time = form.cleaned_data['from_time'] to_date = form.cleaned_data['to_date'] to_time = form.cleaned_data['to_time'] description = form.cleaned_data['description'] - aub = Aub(from_date=from_date, from_time=from_time, to_date=to_date, to_time=to_time, description=description, created_by=request.user) + aub = Aub(from_date=from_date, from_time=from_time, to_date=to_date, to_time=to_time, description=description, + created_by=request.user) aub.save() a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung gestellt", @@ -92,6 +97,7 @@ def apply_for(request): return redirect('aub_applied_for') return render(request, 'aub/apply_for.html', {'form': form}) + # # Form is filled # if request.method == 'POST': # # get form via edit-button @@ -119,40 +125,40 @@ def apply_for(request): # # return render(request, 'aub/apply_for.html', {'form': form, 'from_dt': instance.from_dt}) # return render(request, 'aub/apply_for.html', {'form': form}) - # if request.method == 'POST': - # - # if 'aub-id' in request.POST: - # aub_id = request.POST['aub-id'] - # aub = Aub.objects.get(id=aub_id) - # print('AUB:', aub_id, '|', aub.from_dt, '|', aub.to_dt, '|', aub.description) - # form = ApplyForAUBForm(request.POST, instance=aub) - # else: - # form = ApplyForAUBForm(request.POST) - # # form = ApplyForAUBForm(request.POST, initial=[aub.from_dt, aub.to_dt, aub.description]) - # if form.is_valid(): - # from_dt = timezone.datetime.combine(form.cleaned_data['from_date'], form.cleaned_data['from_time']) - # to_dt = timezone.datetime.combine(form.cleaned_data['to_date'], form.cleaned_data['to_time']) - # description = form.cleaned_data['description'] - # - # aub = Aub(from_dt=from_dt, to_dt=to_dt, description=description, created_by=request.user) - # aub.save() - # - # a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung gestellt", - # description="Sie haben einen Antrag auf Unterrichtsbefreiung " + - # "für den Zeitraum von {} bis {} gestellt.".format( - # aub.from_dt, aub.to_dt), app=AubConfig.verbose_name) - # a.save() - # - # return redirect(reverse('aub_applied_for')) - # - # else: - # form = ApplyForAUBForm() - # - # context = { - # 'Aub': aub, - # 'form': form, - # } - # return render(request, 'aub/apply_for.html', context) +# if request.method == 'POST': +# +# if 'aub-id' in request.POST: +# aub_id = request.POST['aub-id'] +# aub = Aub.objects.get(id=aub_id) +# print('AUB:', aub_id, '|', aub.from_dt, '|', aub.to_dt, '|', aub.description) +# form = ApplyForAUBForm(request.POST, instance=aub) +# else: +# form = ApplyForAUBForm(request.POST) +# # form = ApplyForAUBForm(request.POST, initial=[aub.from_dt, aub.to_dt, aub.description]) +# if form.is_valid(): +# from_dt = timezone.datetime.combine(form.cleaned_data['from_date'], form.cleaned_data['from_time']) +# to_dt = timezone.datetime.combine(form.cleaned_data['to_date'], form.cleaned_data['to_time']) +# description = form.cleaned_data['description'] +# +# aub = Aub(from_dt=from_dt, to_dt=to_dt, description=description, created_by=request.user) +# aub.save() +# +# a = Activity(user=request.user, title="Antrag auf Unterrichtsbefreiung gestellt", +# description="Sie haben einen Antrag auf Unterrichtsbefreiung " + +# "für den Zeitraum von {} bis {} gestellt.".format( +# aub.from_dt, aub.to_dt), app=AubConfig.verbose_name) +# a.save() +# +# return redirect(reverse('aub_applied_for')) +# +# else: +# form = ApplyForAUBForm() +# +# context = { +# 'Aub': aub, +# 'form': form, +# } +# return render(request, 'aub/apply_for.html', context) # @login_required @@ -209,6 +215,7 @@ def edit(request, id): } return render(request, template, context) + @login_required @permission_required('aub.apply_for_aub') def applied_for(request): @@ -250,10 +257,10 @@ def check2(request): register_notification(title="Ihr Antrag auf Unterrichtsbefreiung wurde genehmigt", description="Ihr Antrag auf Unterrichtsbefreiung vom {} bis {} wurde von der " "Schulleitung genehmigt.".format( -# formats.date_format(aub.from_dt), -# formats.date_format(aub.to_dt)), - formats.date_format(aub.from_date), - formats.date_format(aub.to_date)), + # formats.date_format(aub.from_dt), + # formats.date_format(aub.to_dt)), + formats.date_format(aub.from_date), + formats.date_format(aub.to_date)), app=AubConfig.verbose_name, user=aub.created_by, link=request.build_absolute_uri(reverse('aub_details', args=[aub.id]))) elif 'deny' in request.POST: @@ -265,11 +272,11 @@ def check2(request): description="Ihr Antrag auf Unterrichtsbefreiung vom {} bis {} wurde von der " "Schulleitung abgelehnt. Für weitere Informationen kontaktieren Sie " "bitte die Schulleitung.".format( -# formats.date_format(aub.from_dt), -# formats.date_format(aub.to_dt)), + # formats.date_format(aub.from_dt), + # formats.date_format(aub.to_dt)), formats.date_format(aub.from_date), formats.date_format(aub.to_date)), - app=AubConfig.verbose_name, user=aub.created_by, + app=AubConfig.verbose_name, user=aub.created_by, link=request.build_absolute_uri(reverse('aub_details', args=[aub.id]))) aub_list = Aub.objects.all().order_by('status') diff --git a/schoolapps/static/common/helper.js b/schoolapps/static/common/helper.js index fb71146384e3b77c1d341b2004cef14c5d0eba48..5ffe85bbc1fe6f8dd2fc7941b95fa2f70dfb6538 100644 --- a/schoolapps/static/common/helper.js +++ b/schoolapps/static/common/helper.js @@ -53,6 +53,9 @@ function setTime(lesson_field) { } $(document).ready(function () { + $("dmc-datetime input").addClass("datepicker"); + $("[data-form-control='time']").addClass("timepicker"); + // Initialize sidenav [MAT] $(".sidenav").sidenav(); diff --git a/schoolapps/static/common/style.css b/schoolapps/static/common/style.css index 5187375e1c2c1e13697e44c26a1d34b7367b89c2..beba8a06c52f4eaede4cb6922264853fbfd47ea0 100755 --- a/schoolapps/static/common/style.css +++ b/schoolapps/static/common/style.css @@ -82,6 +82,15 @@ ul.collection .collection-item .title { font-weight: bold; } +.section { + padding: 0; +} + +form .row { + margin-top: 0; + margin-bottom: 0; +} + /* Badges */ span.badge.new::after {