Files
TimeTracker/app/models/__init__.py
Dries Peeters d530ce48b0 feat: Add Weekly Time Goals feature for tracking weekly hour targets
Implemented a comprehensive Weekly Time Goals system that allows users to set
and track weekly hour targets with real-time progress monitoring.

Features:
- WeeklyTimeGoal model with status tracking (active, completed, failed, cancelled)
- Full CRUD interface for managing weekly goals
- Real-time progress calculation based on logged time entries
- Dashboard widget showing current week's goal progress
- Daily breakdown view with detailed statistics
- Automatic status updates based on goal completion and week end
- API endpoints for goal data and progress tracking

Technical changes:
- Added app/models/weekly_time_goal.py with local timezone support
- Created migration 027_add_weekly_time_goals.py for database schema
- Added app/routes/weekly_goals.py blueprint with all CRUD routes
- Created templates: index.html, create.html, edit.html, view.html
- Integrated weekly goal widget into main dashboard
- Added "Weekly Goals" navigation item to sidebar
- Implemented comprehensive test suite in tests/test_weekly_goals.py
- Added feature documentation in docs/WEEKLY_TIME_GOALS.md

Bug fixes:
- Fixed timezone handling to use TZ environment variable instead of Config.TIMEZONE
- Corrected log_event() calls to use proper signature (event name as first positional argument)
- Manually created database table via SQL when Alembic migration didn't execute

Database schema:
- weekly_time_goals table with user_id, target_hours, week_start_date, week_end_date, status, notes
- Indexes on user_id, week_start_date, status, and composite (user_id, week_start_date)
- Foreign key constraint to users table with CASCADE delete

The feature supports flexible week start days per user, calculates remaining hours,
provides daily average targets, and automatically updates goal status based on progress.
2025-10-24 10:15:03 +02:00

60 lines
1.6 KiB
Python

from .user import User
from .project import Project
from .time_entry import TimeEntry
from .task import Task
from .settings import Settings
from .invoice import Invoice, InvoiceItem
from .invoice_template import InvoiceTemplate
from .currency import Currency, ExchangeRate
from .tax_rule import TaxRule
from .payments import Payment, CreditNote, InvoiceReminderSchedule
from .reporting import SavedReportView, ReportEmailSchedule
from .client import Client
from .task_activity import TaskActivity
from .extra_good import ExtraGood
from .comment import Comment
from .focus_session import FocusSession
from .recurring_block import RecurringBlock
from .rate_override import RateOverride
from .saved_filter import SavedFilter
from .project_cost import ProjectCost
from .kanban_column import KanbanColumn
from .time_entry_template import TimeEntryTemplate
from .activity import Activity
from .user_favorite_project import UserFavoriteProject
from .client_note import ClientNote
from .weekly_time_goal import WeeklyTimeGoal
__all__ = [
"User",
"Project",
"TimeEntry",
"Task",
"Settings",
"Invoice",
"InvoiceItem",
"Client",
"TaskActivity",
"Comment",
"FocusSession",
"RecurringBlock",
"RateOverride",
"SavedFilter",
"ProjectCost",
"InvoiceTemplate",
"Currency",
"ExchangeRate",
"TaxRule",
"Payment",
"CreditNote",
"InvoiceReminderSchedule",
"SavedReportView",
"ReportEmailSchedule",
"KanbanColumn",
"TimeEntryTemplate",
"Activity",
"UserFavoriteProject",
"ClientNote",
"WeeklyTimeGoal",
]