odoo_hours setup and ready

This commit is contained in:
2024-11-25 19:11:28 +00:00
parent 78241144e2
commit 111c51a072
8 changed files with 353 additions and 11 deletions

View File

@@ -1,3 +1,23 @@
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")