You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
3.1 KiB
78 lines
3.1 KiB
from django.shortcuts import render, redirect
|
|
from django.contrib.auth.decorators import login_required
|
|
import datetime
|
|
from . import models as MainModel
|
|
|
|
def actualMonday():
|
|
today = datetime.date.today()
|
|
last_monday = today - datetime.timedelta(days=today.weekday())
|
|
return last_monday
|
|
|
|
def FutureyDate(date, FutureWeeks):
|
|
date = date + datetime.timedelta(weeks=FutureWeeks)
|
|
return date
|
|
|
|
def PastDate(date, FutureWeeks):
|
|
date = date - datetime.timedelta(weeks=FutureWeeks)
|
|
return date
|
|
|
|
def separate_string(input_string):
|
|
separated_string = ""
|
|
index = 1
|
|
for i in input_string:
|
|
if index == 2:
|
|
separated_string += i + "."
|
|
index = 0
|
|
else:
|
|
separated_string += i
|
|
index += 1
|
|
|
|
return separated_string[:8]
|
|
|
|
@login_required
|
|
def index(request):
|
|
error = False
|
|
if request.GET.get("date"):
|
|
actual = False
|
|
actualdate = actualMonday()
|
|
get_Date = separate_string(request.GET.get("date"))
|
|
url_date = datetime.datetime.strptime(get_Date, "%d.%m.%y")
|
|
if url_date.date() <= actualdate or url_date.weekday() != 0:
|
|
url_date = actualdate
|
|
actual = True
|
|
error = True
|
|
elif url_date.date() == actualdate:
|
|
actual = True
|
|
else:
|
|
url_date = actualMonday()
|
|
actual = True
|
|
|
|
strDate = url_date.strftime("%d.%m.%y")
|
|
|
|
# Abfrage der Datenbanken um Informationen einzublenden
|
|
|
|
steward_data = MainModel.steward.objects.filter(week__date_of_monday=strDate)[0]
|
|
regie_data = MainModel.regie.objects.filter(week__date_of_monday=strDate)[0]
|
|
|
|
persons = MainModel.contributors.objects.all()
|
|
|
|
return render(request, 'main/index.html', {'actual' : actual,
|
|
'error' : error,
|
|
'date': strDate,
|
|
'next_date': FutureyDate(url_date, 1).strftime("%d%m%y"),
|
|
'past_date': PastDate(url_date, 1).strftime("%d%m%y"),
|
|
'saal_ordner' : persons.filter(saalordner=True),
|
|
'ordner' : persons.filter(ordner=True),
|
|
'anlage' : persons.filter(anlage=True),
|
|
'zoom' : persons.filter(zoom=True),
|
|
'buehne' : persons.filter(buehne=True),
|
|
'sm' : persons.filter(treffpunkt=True),
|
|
'date_area' : {
|
|
'min' : str(url_date),
|
|
'value' : str(url_date),
|
|
'max' : str(FutureyDate(url_date - datetime.timedelta(days=1), 1))},
|
|
'steward_data' : steward_data,
|
|
'regie_data' : regie_data,
|
|
})
|
|
|