Skip to content
Snippets Groups Projects
Commit 3fafc842 authored by Jonathan Weth's avatar Jonathan Weth :keyboard: Committed by root
Browse files

Merge branch 'dev' into smartplan

parents 0ce17fe3 d07a580e
No related branches found
No related tags found
1 merge request!86Merge school-apps
Showing
with 471 additions and 99 deletions
# school-apps
## Apps
### In Betrieb
keine
### Im Testbetrieb
keine
### In der Entwicklung
- **Dashboard**: Verwaltet Aktivitäten und Benachrichtigungen (welche auch per E-Mail versendet werden, dient also auch zum E-Mail-Versand)
- **AUB**: Antrag auf Unterrichtsbefreiung
- **Timetable**: Anzeige des Stundenplans, Vertretungsplan fehlt noch
### Ideen (bestätigt)
- Vertretungsplan
- Klausurenplan
- Einbindung von ILIAS-Raumbuchungen in Stundenplan
- REBUS
### Ideen (unbestätigt)
- Speiseplan
- Elternsprechtag
- Bundesjungendspiele
- Chat
siehe Wiki
## Installation
**Hinweis:** Es wird aktuell nur ein aktuelles Debian, Ubuntu, Linux Mint, etc. unterstützt.
### Grundsystem
......
......@@ -3,8 +3,7 @@ from django.core.exceptions import ValidationError
from django.utils import timezone
from datetime import datetime
from material import Layout, Row, Fieldset
from schoolapps import settings
from aub.models import Aub
class FilterAUBForm(forms.Form):
timerangechoices = [('today','Heute'),('thisWeek','Diese Woche'), ('thisMonth','Dieser Monat')]
......@@ -21,16 +20,17 @@ class FilterAUBForm(forms.Form):
def clean(self):
cleaned_data = super().clean()
class ApplyForAUBForm(forms.Form):
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=settings.LESSONS, required=False,
widget=forms.Select(attrs={'onchange': 'setTime(this)'}))
from_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial='8:00', )
from_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(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=settings.LESSONS, required=False,
widget=forms.Select(attrs={'onchange': 'setTime(this)'}))
to_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial='15:35')
to_lesson = forms.ChoiceField(label='Stunde', choices=lessons, required=False, widget=forms.Select(attrs = {'onchange' : 'set_time(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.')
layout = Layout(Fieldset('Von',
......@@ -43,16 +43,20 @@ class ApplyForAUBForm(forms.Form):
'description'),
)
class Meta:
model = Aub
fields = ('id', 'from_date', 'from_time', 'to_date', 'to_time', 'description')
def clean(self):
cleaned_data = super().clean()
def clean_from_to_date(self):
# not related to a form field, just to clean datetime values
from_date = self.cleaned_data['from_date']
from_lesson = self.cleaned_data['from_lesson']
# from_lesson = self.cleaned_data['from_lesson']
from_time = self.cleaned_data['from_time']
to_date = self.cleaned_data['to_date']
to_lesson = self.cleaned_data['to_lesson']
# to_lesson = self.cleaned_data['to_lesson']
to_time = self.cleaned_data['to_time']
from_datetime = timezone.datetime.combine(from_date, from_time)
print(from_datetime)
......@@ -72,3 +76,84 @@ class ApplyForAUBForm(forms.Form):
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.')]
# 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_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial='8:00', )
# 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_time = forms.TimeField(label='Zeit', input_formats=['%H:%M'], initial='15:35')
#
# description = forms.CharField(label='Bitte begründen Sie Ihren Antrag.')
#
# layout = Layout(Fieldset('Von',
# Row('from_date', 'from_lesson', 'from_time'),
# ),
# Fieldset('Bis',
# Row('to_date', 'to_lesson', 'to_time'),
# ),
# Fieldset('Grund / Vorhaben',
# 'description'),
# )
#
# def clean(self):
# cleaned_data = super().clean()
#
# def clean_from_to_date(self):
# # not related to a form field, just to clean datetime values
# from_date = self.cleaned_data['from_date']
# from_lesson = self.cleaned_data['from_lesson']
# from_time = self.cleaned_data['from_time']
# to_date = self.cleaned_data['to_date']
# to_lesson = self.cleaned_data['to_lesson']
# to_time = self.cleaned_data['to_time']
# from_datetime = timezone.datetime.combine(from_date, from_time)
# print(from_datetime)
# to_datetime = timezone.datetime.combine(to_date, to_time)
# if (from_datetime < datetime.now()) or (to_datetime < datetime.now()):
# raise ValidationError(
# 'Die Befreiung kann nicht für bereits vergangene Tage durchgeführt werden (Datumsfehler).')
# elif from_datetime > to_datetime:
# raise ValidationError('Das Von-Datum liegt hinter dem Bis-Datum.')
# return True
#
# # def clean_from_date(self):
# # data = self.cleaned_data['from_date']
# # # if data < timezone.datetime.date(timezone.now()):
# # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden (Datumsfehler).')
# # return data
# #
# # def clean_to_date(self):
# # data = self.cleaned_data['to_date']
# # # if data < timezone.datetime.date(timezone.now()):
# # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden.')
# # return data
# #
# # def clean_from_time(self):
# # data = self.cleaned_data['from_time']
# # # print('Data:', type(data), 'Now:', type(timezone.datetime.time(timezone.now())))
# #
# # # if data < timezone.datetime.time(timezone.now()):
# # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden (Zeitfehler).')
# #
# # return data
# #
# # def clean_to_time(self):
# # data = self.cleaned_data['to_time']
# #
# # # if data < timezone.datetime.time(timezone.now()):
# # # raise ValidationError('Die Befreiung kann nur zukünftig durchgeführt werden.')
# # return data
#
# def clean_description(self):
# data = self.cleaned_data['description']
# self.clean_from_to_date()
# if len(data) < 10:
# raise ValidationError('Bitte teilen Sie uns etwas mehr über Ihren Befreiungswunsch mit.')
#
# return data
# Generated by Django 2.1.2 on 2018-12-23 08:05
import datetime
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('aub', '0002_aub_status'),
]
operations = [
migrations.RemoveField(
model_name='aub',
name='from_dt',
),
migrations.RemoveField(
model_name='aub',
name='to_dt',
),
migrations.AddField(
model_name='aub',
name='from_date',
field=models.DateField(default=datetime.date.today),
),
migrations.AddField(
model_name='aub',
name='from_time',
field=models.TimeField(default=django.utils.timezone.now),
),
migrations.AddField(
model_name='aub',
name='to_date',
field=models.DateField(default=datetime.date.today),
),
migrations.AddField(
model_name='aub',
name='to_time',
field=models.TimeField(default=django.utils.timezone.now),
),
]
# Generated by Django 2.0.7 on 2018-11-28 16:09
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('aub', '0004_auto_20181031_1617'),
]
operations = [
migrations.AlterField(
model_name='aub',
name='created_by',
field=models.ForeignKey(default=3, on_delete=models.SET(3), related_name='aubs',
to=settings.AUTH_USER_MODEL),
),
]
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from datetime import date
def get_default_user():
user, created = User.objects.get_or_create(username='nouser')
......@@ -22,8 +23,12 @@ def get_default_status():
class Aub(models.Model):
# Time
from_dt = models.DateTimeField(default=timezone.now)
to_dt = models.DateTimeField(default=timezone.now)
# from_dt = models.DateTimeField(default=timezone.now)
# to_dt = models.DateTimeField(default=timezone.now)
from_date = models.DateField(default=date.today)
from_time = models.TimeField(default=timezone.now)
to_date = models.DateField(default=date.today)
to_time = models.TimeField(default=timezone.now)
# Information
description = models.TextField()
......
......@@ -4,10 +4,12 @@
<main>
<h5>Antrag auf Unterrichtsbefreiung</h5>
<form method = "POST" >
{% csrf_token %}
{# Von#}
{# <input type="text" label="Von" input_formats=['%d.%m.%Y'] value="{{ from_dt }}" name="from_date" >#}
{% form form=form %}
{# {% part form.from_lesson prefix %}<div></div>{% endpart %} #}
{% endform %}
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Antrag stellen
......
......@@ -7,9 +7,9 @@
<i class="material-icons left"></i> Filter aktualisieren
</button>
</form>
<h5>Ausstehende Anträge</h5>
<ul class="collection">
{# {% for aub in aubs %}#}
{% for aub in filter.qs %}
......@@ -20,7 +20,8 @@
<p class="title">
<span class="item-text">
<i class="material-icons">access_time</i>
{{ aub.from_dt }} bis {{ aub.to_dt }}
{# {{ 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>
......
{% include 'partials/header.html' %}
<main>
<h5>{{ aub.from_dt }} bis {{ aub.to_dt }}</h5>
{# <h5>{{ aub.from_dt }} bis {{ aub.to_dt }}</h5>#}
<h5>{{ aub.from_date }} bis {{ aub.to_date }}</h5>
<p><strong>Status: <span class="badge new {{ aub.status.style_classes }}">{{ aub.status.name }}</span></strong></p>
<p>{{ aub.description }}</p>
<hr>
......
{% include 'partials/header.html' %}
{% load material_form %}
<main>
<h5>Antrag auf Unterrichtsbefreiung</h5>
<form method = "POST" >
{% csrf_token %}
{# <input type="hidden" value="{{ id }}" name="id" />#}
{% form form=form %}
{% endform %}
<button type="submit" class="waves-effect waves-light btn green">
<i class="material-icons left">send</i> Antrag stellen
</button>
</form>
</main>
{% include 'partials/footer.html' %}
......@@ -17,7 +17,8 @@
<p class="title">
<span class="item-text">
<i class="material-icons">access_time</i>
{{ aub.from_dt }} bis {{ aub.to_dt }}
{# {{ aub.from_dt }} bis {{ aub.to_dt }}#}
{{ aub.from_date }}, {{ aub.from_time }} bis {{ aub.to_date }}, {{ aub.to_time }}
</span>
</p>
<p><a href="{% url 'aub_details' aub.id %}">{{ aub.description }}</a></p>
......@@ -32,20 +33,25 @@
</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 == 1 %}
<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>
{% endif %}
{% if aub.status_id == 1 or aub.status_id == 2 %}
<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>
{% endif %}
</form>
{% 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">
<i class="material-icons center red-text">cancel</i>
</button>
</form>
{% endif %}
</p>
</div>
......
......@@ -4,8 +4,9 @@ from . import views
urlpatterns = [
path('', views.index, name='aub_index'),
path('details/<int:aub_id>/', views.details, name='aub_details'),
path('details/<int:id>', views.details, name='aub_details'),
path('apply_for', views.apply_for, name='aub_apply_for'),
path('edit/<int:id>', views.edit, name='aub_edit'),
path('applied_for', views.applied_for, name='aub_applied_for'),
path('check1', views.check1, name='aub_check1'),
path('check2', views.check2, name='aub_check2'),
......
......@@ -3,7 +3,9 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.urls import reverse
from django.utils import timezone
from django.utils import formats
from datetime import date
from datetime import datetime as dt
from django.core.exceptions import ValidationError
from .apps import AubConfig
from dashboard.models import Activity, register_notification
......@@ -20,8 +22,22 @@ NOT_ALLOWED_STATUS = Status.objects.get_or_create(name='Abgelehnt', style_classe
@login_required
@permission_required('aub.apply_for_aub')
def index(request):
if 'aub-id' in request.POST:
id = request.POST['aub-id']
# Edit button pressed?
if 'edit' in request.POST:
instance = Aub.objects.filter(id=id)
print('...Edit wurde gewählt')
# return render(request, 'aub/apply_for.html', {'filter': instance})
apply_for(request, id=id)
# Cancel button pressed?
elif 'cancel' in request.POST:
instance = Aub.objects.get(id=id)
instance.delete()
print('Eintrag gelöscht')
# order_crit = '-created_at'
order_crit = 'from_dt'
order_crit = 'from_date'
aubs = Aub.objects.filter(created_by=request.user).order_by(order_crit)[:100]
context = {
......@@ -32,8 +48,8 @@ def index(request):
@login_required
@permission_required('aub.apply_for_aub')
@check_own_aub(login_url='/index.html')
def details(request, aub_id):
aub = get_object_or_404(Aub, id=aub_id)
def details(request, id):
aub = get_object_or_404(Aub, id=id)
context = {
'aub': aub
}
......@@ -43,34 +59,155 @@ def details(request, aub_id):
@permission_required('aub.apply_for_aub')
def apply_for(request):
if request.method == 'POST':
form = ApplyForAUBForm(request.POST)
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'))
print('Fall 1 - ')
if 'aub-id' in request.POST:
id = request.POST['aub-id']
instance = Aub.objects.get(id=id)
form = ApplyForAUBForm(instance=instance)
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)
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()
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']
context = {
'form': form,
}
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",
description="Sie haben einen Antrag auf Unterrichtsbefreiung " +
"für den Zeitraum von {} bis {} gestellt.".format(
aub.from_date, aub.to_date), app=AubConfig.verbose_name)
a.save()
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
# if 'aub-id' in request.POST:
# id = request.POST['aub-id']
# # instance = get_object_or_404(Aub, id=id)
# instance = Aub.objects.get(id=id)
# print('AUB:', id, '|', instance.from_date, '|', instance.to_date, '|', instance.description)
# #instance.description = 'Mal was ganz anderes'
# form = ApplyForAUBForm(request.POST, instance=instance)
# #print('Form ist valid? IF:', instance.created_by, instance.to_date, instance.id)
# return render(request, 'aub/apply_for.html', {'form': form})
# # get a new item
# else:
# form = ApplyForAUBForm(request.POST or None)
# print('Form ist valid? ELSE:', form.errors)
# if form.is_valid():
# print('Form ist valid!', form.errors)
# aub = form.save()
# print('aub-id:', aub.id)
# aub.created_by = request.user
# aub.save()
# return redirect('aub_applied_for')
# form = ApplyForAUBForm()
# # return render(request, 'aub/apply_for.html', {'form': form, 'from_dt': instance.from_dt})
# return render(request, 'aub/apply_for.html', {'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
# @permission_required('aub.apply_for_aub')
# def apply_for(request):
# 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
@permission_required('aub.apply_for_aub')
def edit(request, id):
aub = get_object_or_404(Aub, id=id)
form = ApplyForAUBForm(instance=aub)
template = 'aub/edit.html'
if request.method == 'POST':
form = ApplyForAUBForm(request.POST, instance=aub)
if form.is_valid():
form.save()
return redirect(reverse('aub_applied_for'))
context = {
'form': form
}
return render(request, template, context)
@login_required
@permission_required('aub.apply_for_aub')
......@@ -87,21 +224,15 @@ def applied_for(request):
def check1(request):
if request.method == 'POST':
if 'aub-id' in request.POST:
aub_id = request.POST['aub-id']
id = request.POST['aub-id']
if 'allow' in request.POST:
Aub.objects.filter(id=aub_id).update(status=SEMI_ALLOWED_STATUS)
Aub.objects.filter(id=id).update(status=SEMI_ALLOWED_STATUS)
elif 'deny' in request.POST:
Aub.objects.filter(id=aub_id).update(status=NOT_ALLOWED_STATUS)
Aub.objects.filter(id=id).update(status=NOT_ALLOWED_STATUS)
aub_list = Aub.objects.all().order_by('status')
aubs = AUBFilter(request.GET, queryset=aub_list)
return render(request, 'aub/check.html', {'filter': aubs})
#aubs = Aub.objects.filter(status=IN_PROCESSING_STATUS)
#context = {
# 'aubs': aubs
#}
#return render(request, 'aub/check.html', context)
@login_required
......@@ -109,39 +240,39 @@ def check1(request):
def check2(request):
if request.method == 'POST':
if 'aub-id' in request.POST:
aub_id = request.POST['aub-id']
aub = Aub.objects.get(id=aub_id)
id = request.POST['aub-id']
aub = Aub.objects.get(id=id)
if 'allow' in request.POST:
# Update status
Aub.objects.filter(id=aub_id).update(status=ALLOWED_STATUS)
Aub.objects.filter(id=id).update(status=ALLOWED_STATUS)
# Notify user
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_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:
# Update status
Aub.objects.filter(id=aub_id).update(status=NOT_ALLOWED_STATUS)
Aub.objects.filter(id=id).update(status=NOT_ALLOWED_STATUS)
# Notify user
register_notification(title="Ihr Antrag auf Unterrichtsbefreiung wurde abgelehnt",
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)),
app=AubConfig.verbose_name, user=aub.created_by,
# 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])))
aub_list = Aub.objects.all().order_by('status')
aubs = AUBFilter(request.GET, queryset=aub_list)
# aubs = Aub.objects.filter(status=SEMI_ALLOWED_STATUS)
# context = {
# 'aubs': aubs
# }
return render(request, 'aub/check.html', {'filter': aubs})
# return render(request, 'aub/check.html', context)
import os
from uuid import uuid4
from django.template.loader_tags import register
def path_and_rename(instance, filename):
upload_to = 'menus'
ext = filename.split('.')[-1].lower()
# get filename
if instance.pk:
filename = '{}.{}'.format(instance.pk, ext)
else:
# set filename as random string
filename = '{}.{}'.format(uuid4().hex, ext)
# return the whole path to the file
return os.path.join(upload_to, filename)
@register.inclusion_tag("components/msgbox.html")
def msg_box(msg, color="red", icon="info"):
return {"msg": msg, "color": color, "icon": icon}
from django.contrib import admin
# Register your models here.
from menu.models import Menu
admin.site.register(Menu)
from django.apps import AppConfig
class MenuConfig(AppConfig):
name = 'menu'
File added
File added
from django import forms
from django.core.validators import FileExtensionValidator
from django.utils import timezone
from menu.models import Menu
current_year = timezone.datetime.now().year
options_for_year = [(current_year, current_year),
(current_year + 1, current_year + 1)]
class MenuUploadForm(forms.ModelForm):
calendar_week = forms.ChoiceField(label="KW", choices=[(cw, cw) for cw in range(1, 53)])
year = forms.ChoiceField(label="Jahr", initial=timezone.datetime.now().year,
choices=options_for_year)
pdf = forms.FileField(label="PDF-Datei", validators=[FileExtensionValidator(allowed_extensions=["pdf"])])
class Meta:
model = Menu
fields = ("calendar_week", "year", "pdf")
# Generated by Django 2.0.7 on 2018-11-28 16:14
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='MealPlan',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('calendar_week', models.IntegerField()),
('year', models.IntegerField()),
('pdf', models.FileField(upload_to='mealplan/%Y/')),
],
),
]
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