mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-19 12:50:11 -05:00
7dcd58608a
Add comprehensive audit logging for TimeEntry operations including: - Client/project context and creation timestamps - Full entity state before/after changes - User-provided reasons for deletions and modifications - Enhanced UI for entering reasons in delete/edit dialogs Database Changes: - Add migration 114: reason, entity_metadata, full_old_state, full_new_state columns - Use JSON column type for entity_metadata for better type handling Model Updates: - Extend AuditLog model with new fields and helper methods - Update log_change() to accept reason, metadata, and full states - Add get_entity_metadata(), get_full_old_state(), get_full_new_state() methods - Use JSON column for entity_metadata (returns dict/list directly) Service Layer: - Update TimeTrackingService to capture full TimeEntry state and metadata - Accept reason parameter in delete_entry() and update_entry() - Create comprehensive audit logs with all context API Routes: - Update api.py, api_v1.py, and timer.py routes to accept reason parameter - Refactor routes to use service layer for consistent audit logging - Add reason support to bulk delete operations UI Enhancements: - Add reason textarea to bulk delete confirmation dialog - Add reason textarea to time entry edit forms (admin and regular users) - Update JavaScript to handle reason submission Audit Log Display: - Show client/project information and creation timestamp in list view - Display full old/new states, reason, and metadata in detail view - Format JSON states for better readability Bug Fixes: - Fix duration_seconds reference in timer stop route - Improve error handling in timer operations with proper exception handling - Add dashboard cache invalidation after manual entry creation