23 lines
1003 B
Python
23 lines
1003 B
Python
from django.shortcuts import render
|
|
from datetime import datetime
|
|
from .text_conv import generate_monthly_summary, process_input_txt
|
|
# Create your views here.
|
|
|
|
def index(request):
|
|
if request.method == "POST":
|
|
input_text = request.POST.get("input_text", "")
|
|
if input_text:
|
|
# Przetwarzanie tekstu
|
|
try:
|
|
work_records = process_input_txt(input_text)
|
|
last_day = work_records[-1]["enter"].date()
|
|
empty_days = datetime(year=last_day.year, month=last_day.month, day=1).weekday()
|
|
monthly_summary = generate_monthly_summary(work_records, last_day.year, last_day.month)
|
|
return render(request, "calendar.html", {
|
|
"days": monthly_summary,
|
|
"empty_days": range(empty_days),
|
|
})
|
|
except:
|
|
return render(request, "hours_form.html", {"error": "Cos poszlo nie tak!"})
|
|
|
|
return render(request, "hours_form.html") |