major fm updates

This commit is contained in:
buenosairesam
2025-12-19 22:47:38 -03:00
parent 0dde9f1f54
commit 23b4341842
7 changed files with 197 additions and 116 deletions

View File

@@ -19,7 +19,12 @@ def calendar_view(scope="daily", year=None, month=None, day=None):
"""
Google Calendar-style view showing task blocks at their actual times.
"""
from flask import request
task = None
grid = int(request.args.get('grid', 1)) # Grid hours: 1, 3, or 6
if grid not in [1, 3, 6]:
grid = 1
if not year:
year = datetime.today().year
@@ -33,7 +38,7 @@ def calendar_view(scope="daily", year=None, month=None, day=None):
if scope == "daily":
start = base_date
end = base_date.replace(hour=23, minute=59, second=59)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=60)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=60, grid_hours=grid)
prev_date = base_date - timedelta(days=1)
next_date = base_date + timedelta(days=1)
days = [base_date]
@@ -41,7 +46,7 @@ def calendar_view(scope="daily", year=None, month=None, day=None):
elif scope == "weekly":
start = base_date - timedelta(days=base_date.weekday())
end = start + timedelta(days=6, hours=23, minutes=59, seconds=59)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=300)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=300, grid_hours=grid)
prev_date = start - timedelta(days=7)
next_date = start + timedelta(days=7)
days = [start + timedelta(days=i) for i in range(7)]
@@ -52,7 +57,7 @@ def calendar_view(scope="daily", year=None, month=None, day=None):
end = datetime(year + 1, 1, 1, tzinfo=timezone) - timedelta(seconds=1)
else:
end = datetime(year, month + 1, 1, tzinfo=timezone) - timedelta(seconds=1)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=600)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=600, grid_hours=grid)
if month == 1:
prev_date = datetime(year - 1, 12, 1, tzinfo=timezone)
else:
@@ -70,7 +75,7 @@ def calendar_view(scope="daily", year=None, month=None, day=None):
scope = "daily"
start = base_date
end = base_date.replace(hour=23, minute=59, second=59)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=60)
blocks = get_task_blocks_calendar(start, end, task, min_block_seconds=60, grid_hours=grid)
prev_date = base_date - timedelta(days=1)
next_date = base_date + timedelta(days=1)
days = [base_date]
@@ -85,6 +90,7 @@ def calendar_view(scope="daily", year=None, month=None, day=None):
prev_date=prev_date,
next_date=next_date,
days=days,
grid=grid,
auto_refresh=False
)