Commit Graph

505 Commits

Author SHA1 Message Date
Dries Peeters
39cf649f8e feat: Add client portal with password setup email functionality
Implement a complete client portal feature that allows clients to access
their projects, invoices, and time entries through a dedicated portal with
separate authentication. Includes password setup via email with secure
token-based authentication.

Client Portal Features:
- Client-based authentication (separate from user accounts)
- Portal access can be enabled/disabled per client
- Clients can view their projects, invoices, and time entries
- Clean, minimal UI without main app navigation elements
- Login page styled to match main app design

Password Setup Email:
- Admin can send password setup emails to clients
- Secure token-based password setup (24-hour expiration)
- Email template with professional styling
- Password setup page matching app login design
- Token validation and automatic cleanup after use

Email Configuration:
- Email settings from admin menu are now used for sending
- Database email settings persist between restarts and updates
- Automatic reload of email configuration when sending emails
- Database settings take precedence over environment variables
- Improved error messages for email configuration issues

Database Changes:
- Add portal_enabled, portal_username, portal_password_hash to clients
- Add password_setup_token and password_setup_token_expires to clients
- Migration 047: Add client portal fields to users (legacy)
- Migration 048: Add client portal credentials to clients
- Migration 049: Add password setup token fields

New Files:
- app/routes/client_portal.py - Client portal routes and authentication
- app/templates/client_portal/ - Portal templates (base, login, dashboard, etc.)
- app/templates/email/client_portal_password_setup.html - Email template
- migrations/versions/047-049 - Database migrations
- tests/test_client_portal.py - Portal tests
- docs/CLIENT_PORTAL.md - Portal documentation

Modified Files:
- app/models/client.py - Add portal fields and password token methods
- app/routes/clients.py - Add send password email route
- app/routes/client_portal.py - Portal routes with redirect handling
- app/utils/email.py - Use database settings, add password setup email
- app/templates/clients/edit.html - Add send email button
- app/templates/components/ui.html - Support client portal breadcrumbs

Security:
- Secure token generation using secrets.token_urlsafe()
- Password hashing with werkzeug.security
- Token expiration (24 hours default)
- Token cleared after successful password setup
- CSRF protection on all forms
2025-11-14 15:15:38 +01:00
Dries Peeters
a69cc8d3c1 Merge pull request #272 from DRYTRIX/Feat-Webhook-system
feat: Add webhook system for real-time event notifications
2025-11-14 13:55:51 +01:00
Dries Peeters
a18de04a6a feat: Add webhook system for real-time event notifications
Implement comprehensive webhook system supporting 40+ event types with automatic retries, HMAC signatures, delivery tracking, REST API, and admin UI. Integrates with Activity logging for automatic event triggering.

- Database: Add webhooks and webhook_deliveries tables (migration 046)

- API: Full CRUD endpoints with read:webhooks/write:webhooks scopes

- UI: Admin interface for webhook management and testing

- Service: Automatic retry with exponential backoff every 5 minutes

- Security: HMAC-SHA256 signature verification

- Tests: Model and service tests included

- Docs: Complete integration guide with examples
2025-11-14 13:52:56 +01:00
Dries Peeters
94de87fcf4 Merge pull request #271 from DRYTRIX/Feat-Email-invoice-sending
fix: Fix email template editor initialization and JavaScript errors
2025-11-14 13:41:56 +01:00
Dries Peeters
a4797b25ac fix: Fix email template editor initialization and JavaScript errors
- Fix script block name from extra_js to scripts_extra to match base.html
- Replace inline onclick handlers with event listeners to fix scope issues
- Fix ReferenceError for toggleViewMode and insertVariable functions
- Improve editor initialization flow with proper script loading detection
- Add error handling and fallback to textarea if Toast UI Editor fails to load
- Add debug logging for troubleshooting initialization issues
- Ensure default templates are editable (no restrictions in backend)
- Add email templates link to admin menu in base.html
- Remove ENV file configuration details from email support page

The editor now properly initializes and all interactive features work correctly.
2025-11-14 13:40:00 +01:00
Dries Peeters
f54ab9934f feat(api): add broad API v1 parity, scope UI, and consistency improvements
Backend: add Black/isort/Flake8 configs and .editorconfig; switch health/readiness to locale-based time. Fix service worker asset list; add smoke test.

Admin scopes UI: add read:* and write:* wildcards; add granular scopes for invoices, expenses, payments, mileage, per diem, budget alerts, calendar, comments, recurring invoices.

API v1: add endpoints for invoices, expenses, payments, mileage, per diem (+rates), budget alerts, calendar, kanban, saved filters, time entry templates, comments, recurring invoices, credit notes, client notes (paginated), project costs (paginated), currencies, exchange rates, favorites, audit logs, activities, and invoice PDF/templates (admin). Extend /api/v1/info with all resources. No schema changes.

Tests: add coverage for new endpoints (CRUD/list/pagination) and service worker route smoke test.
2025-11-14 13:09:57 +01:00
Dries Peeters
70d9dad4f3 Big testing update 2025-11-14 12:08:50 +01:00
Dries Peeters
efc25c7843 Update conftest.py 2025-11-13 16:36:09 +01:00
Dries Peeters
dbd48200ab Update conftest.py 2025-11-13 16:23:51 +01:00
Dries Peeters
14d7c5b5e8 Update all tests 2025-11-13 15:19:32 +01:00
Dries Peeters
ce35b6e9b9 Update test_invoices.py 2025-11-13 14:50:32 +01:00
Dries Peeters
ca60e7c9a5 Update test_invoices.py 2025-11-13 14:44:39 +01:00
Dries Peeters
42bc1a3872 Update test_invoices.py 2025-11-13 14:37:53 +01:00
Dries Peeters
2a9715d0ef Update conftest.py 2025-11-13 14:28:30 +01:00
Dries Peeters
8f8e04bda7 Update test_calendar_event_model.py 2025-11-13 14:08:11 +01:00
Dries Peeters
5b55068ced Update test_calendar_event_model.py 2025-11-13 14:04:25 +01:00
Dries Peeters
7c0128bda5 Actually fix the tests? 2025-11-13 13:52:03 +01:00
Dries Peeters
4ddd4fba41 Update test_calendar_event_model.py 2025-11-13 13:12:53 +01:00
Dries Peeters
44cca91739 tests fixed 2025-11-13 12:36:49 +01:00
Dries Peeters
6594d29fb6 update tests 2025-11-13 12:05:35 +01:00
Dries Peeters
dd6f7105ee tests 2025-11-13 11:47:48 +01:00
Dries Peeters
bb77e076ee Fixed tests 2025-11-13 11:27:48 +01:00
Dries Peeters
cc44c1a09e Update conftest.py 2025-11-13 11:22:28 +01:00
Dries Peeters
be62734b59 Update audit_log.py 2025-11-13 10:09:28 +01:00
Dries Peeters
9c91f2a26e feat: Enhance BuyMeACoffee visibility with multiple non-intrusive touchpoints
Improve donation visibility by adding multiple strategic placement options
while maintaining a non-intrusive user experience. Removed footer bar that
was causing layout issues and replaced with better alternatives.

Changes:
- Remove footer bar from all pages to fix layout positioning issues
- Add "Support" button in header (visible on md+ screens) with amber gradient styling
- Add dismissible support banner that appears after 2 seconds with 7-day cooldown
- Enhance sidebar BuyMeACoffee link with gradient background and hover effects
- Keep existing dashboard widget for BuyMeACoffee (gradient card in sidebar)
- Add translation strings for new support-related UI elements

The new approach provides multiple touchpoints:
1. Header button - Always visible but subtle
2. Dismissible banner - Appears occasionally, respects user choice
3. Dashboard widget - Contextual placement on main dashboard
4. Sidebar link - Always accessible in navigation

This ensures users can easily find the donation option without being
overwhelmed by intrusive prompts.
2025-11-13 09:56:56 +01:00
Dries Peeters
0c28b80346 docs: Add comprehensive features documentation and update READMEs
Create complete features overview documenting all 120+ features across
12 major categories, and update main README and docs README with
enhanced feature descriptions and links.

Changes:
- Add docs/FEATURES_COMPLETE.md with comprehensive feature documentation
  covering all features organized by category (Time Tracking, Project
  Management, Task Management, Client Management, Invoicing, Financial
  Management, Reporting & Analytics, User Management & Security,
  Productivity Features, Administration, Integration & API, Technical)
- Update README.md:
  - Add reference to complete features documentation
  - Expand feature descriptions with additional features (Focus Sessions,
    Recurring Time Blocks, Budget Alerts, Weekly Goals, etc.)
  - Enhance feature descriptions with more detail
- Update docs/README.md:
  - Add "Complete Features Reference" section at top
  - Reorganize feature documentation into logical groups
  - Add links to additional feature docs (Payment Tracking, Budget
    Alerts, Weekly Goals, etc.)

This provides users with a single comprehensive reference for all
available features while maintaining the quick overview in the main
README. The documentation is now better organized and more discoverable.
2025-11-13 09:31:07 +01:00
Dries Peeters
b5a5da8ee0 Merge pull request #251 from DRYTRIX/Feat-InvoiceUpdate
feat: Add recurring invoices and email integration with template mana…
2025-11-13 09:26:18 +01:00
Dries Peeters
b4939f4755 feat: Add recurring invoices and email integration with template management
Implement comprehensive recurring invoice system and email functionality with admin interface for managing email templates.

Features: Recurring invoices with scheduling, invoice email integration with PDF attachments, email template management admin interface

Fixes: CSRF tokens, CSS leakage, toast notifications, response body handling, error logging
2025-11-13 09:24:17 +01:00
Dries Peeters
10858ab3cf Merge pull request #250 from DRYTRIX/Feat-Audit-trail/history-tracking-
feat: Add comprehensive audit trail/history tracking system
2025-11-13 08:09:30 +01:00
Dries Peeters
350d7105a2 feat: Add comprehensive audit trail/history tracking system
Implement a complete audit logging system to track all changes made to
tracked entities, providing full compliance and accountability capabilities.

Features:
- Automatic tracking of create, update, and delete operations on 25+ models
- Detailed field-level change tracking with old/new value comparison
- User attribution with IP address, user agent, and request path logging
- Web UI for viewing and filtering audit logs with pagination
- REST API endpoints for programmatic access
- Entity-specific history views
- Comprehensive test coverage (unit, model, route, and smoke tests)

Core Components:
- AuditLog model with JSON-encoded value storage and decoding helpers
- SQLAlchemy event listeners for automatic change detection
- Audit utility module with defensive programming for table existence checks
- Blueprint routes for audit log viewing and API access
- Jinja2 templates for audit log list, detail, and entity history views
- Database migration (044) creating audit_logs table with proper indexes

Technical Implementation:
- Uses SQLAlchemy 'after_flush' event listener to capture changes
- Tracks 25+ models including Projects, Tasks, TimeEntries, Invoices, Clients, Users, etc.
- Excludes sensitive fields (passwords) and system fields (id, timestamps)
- Implements lazy import pattern to avoid circular dependencies
- Graceful error handling to prevent audit logging from breaking core functionality
- Transaction-safe logging that integrates with main application transactions

Fixes:
- Resolved login errors caused by premature transaction commits
- Fixed circular import issues with lazy model loading
- Added table existence checks to prevent errors before migrations
- Improved error handling with debug-level logging for non-critical failures

UI/UX:
- Added "Audit Logs" link to admin dropdown menu
- Organized admin menu into logical sections for better usability
- Filterable audit log views by entity type, user, action, and date range
- Color-coded action badges and side-by-side old/new value display
- Pagination support for large audit log datasets

Documentation:
- Added comprehensive feature documentation
- Included troubleshooting guide and data examples
- Created diagnostic scripts for verifying audit log setup

Testing:
- Unit tests for AuditLog model and value encoding/decoding
- Route tests for all audit log endpoints
- Integration tests for audit logging functionality
- Smoke tests for end-to-end audit trail verification

This implementation provides a robust foundation for compliance tracking
and change accountability without impacting application performance or
requiring code changes in existing routes/models.
2025-11-13 08:08:48 +01:00
Dries Peeters
df64dcbc8f Merge pull request #249 from DRYTRIX/feat-Per-project-Kanban-columns-
feat: Add per-project Kanban columns support
2025-11-13 07:19:22 +01:00
Dries Peeters
85298e1d47 feat: Add per-project Kanban columns support
Implement per-project Kanban column workflows, allowing different projects
to have their own custom kanban board columns and task states.

Changes:
- Add project_id field to KanbanColumn model (nullable, NULL = global columns)
- Create Alembic migration 043 to add project_id column with foreign key
- Update unique constraint from (key) to (key, project_id) to allow same
  keys across different projects
- Update all KanbanColumn model methods to filter by project_id:
  - get_active_columns(project_id=None)
  - get_all_columns(project_id=None)
  - get_column_by_key(key, project_id=None)
  - get_valid_status_keys(project_id=None)
  - initialize_default_columns(project_id=None)
  - reorder_columns(column_ids, project_id=None)
- Update kanban routes to support project filtering:
  - /kanban/columns accepts project_id query parameter
  - /kanban/columns/create supports project selection
  - All CRUD operations redirect to project-filtered view when applicable
  - API endpoints support project_id parameter
- Update project view route to use project-specific columns
- Update task routes to validate status against project-specific columns
- Add fallback logic: projects without custom columns use global columns
- Update UI templates:
  - Add project filter dropdown in column management page
  - Add project selection in create column form
  - Show project info in edit column page
  - Update reorder API calls to include project_id

Database Migration:
- Migration 043 adds project_id column (nullable)
- Existing columns remain global (project_id = NULL)
- New unique constraint on (key, project_id)
- Foreign key constraint with CASCADE delete

Backward Compatibility:
- Existing global columns continue to work
- Projects without custom columns fall back to global columns
- Task status validation uses project-specific columns when available

Impact: High - Enables multi-project teams to have different workflows
per project while maintaining backward compatibility with existing
global column setup.
2025-11-13 07:06:43 +01:00
Dries Peeters
d567dcce7e Merge pull request #248 from DRYTRIX/Fix-Remove-debug logging-in-production
refactor(invoices): standardize logging setup and remove debug logging
2025-11-13 06:42:05 +01:00
Dries Peeters
ac91ad8599 refactor(invoices): standardize logging setup and remove debug logging
- Add module-level logging import and logger initialization
- Remove redundant logging import from export_invoice_pdf function
- Ensure all logging uses proper logger instance instead of print statements
- Improves production logging consistency and respects LOG_LEVEL configuration

Fixes debug logging issues in invoice routes for production readiness.
2025-11-13 06:40:24 +01:00
Dries Peeters
8f9e1db452 Merge pull request #247 from DRYTRIX/Fix-Analytics-date-handling-bug
fix(analytics): resolve strftime error in date handling
2025-11-13 06:34:16 +01:00
Dries Peeters
ae3318c60c fix(analytics): resolve strftime error in date handling
Fixed 'str' object has no attribute 'strftime' error in analytics endpoints by improving date object handling across multiple functions.

- Enhanced weekly_trends() to properly handle string, datetime, and date object types

- Added robust type checking and error handling for date parsing

- Improved hours_by_day() and payments_over_time() with hasattr() checks before strftime() calls

- Added fallback handling to skip invalid date objects gracefully

This prevents analytics dashboard failures when databases return dates in different formats (strings vs date objects).
2025-11-13 06:33:23 +01:00
Dries Peeters
93eabbdd66 Merge pull request #246 from DRYTRIX/Feat-Complete-partially-implemented-features
Complete partially implemented features: templates, activity feed, an…
2025-11-12 11:56:35 +01:00
Dries Peeters
f8f269047e Complete partially implemented features: templates, activity feed, and logging
ented features that were missingUI components, integrations, or proper error handling:1. Time Entry Templates UI Integration   - Added template selector to timer page (timer_page.html)   - Updated timer route to load user templates   - Added JavaScript function to apply templates with one-click   - Created missing view.html template for template details   - Templates now appear on timer page sorted by most recently used2. Activity Feed Widget Real-time Updates   - Added WebSocket integration to Activity model for real-time events   - Activity.log() now emits 'activity_created' SocketIO events   - Updated activity feed widget to listen for WebSocket events   - Feed automatically refreshes when new activities match current filter   - Added proper error handling for WebSocket connection failures3. Invoice Routes Logging Improvements   - Replaced all print() statements with proper logging in invoices.py   - Added structured logging with appropriate log levels (info, debug, warning, error)   - Improved error handling with full traceback logging using exc_info=True   - All PDF export debug statements now use logger.debug/info/errorFiles changed:- app/routes/timer.py: Added template loading for timer page- app/templates/timer/timer_page.html: Added template selector UI and applyTemplate function- app/models/activity.py: Added WebSocket event emission on activity creation- app/templates/components/activity_feed_widget.html: Added WebSocket listener for real-time updates- app/routes/invoices.py: Replaced print statements with proper logging- app/templates/time_entry_templates/view.html: Created missing view template
2025-11-12 11:53:18 +01:00
Dries Peeters
59406b38ee Fix: Filter out done/cancelled tasks in Dashboard Start Timer
When selecting a project in the Dashboard Start Timer modal, all tasks were displayed including those marked as 'done' or 'cancelled'. This made it difficult to find active tasks in projects with many completed tasks.

Changes:

- Updated /api/projects/<project_id>/tasks endpoint to exclude tasks with status 'done' or 'cancelled'

- Only returns active tasks (todo, in_progress, review)

- Added test to verify the filtering behavior

This improves usability by showing only actionable tasks when starting a timer, especially beneficial for larger projects with many tasks.
2025-11-12 11:20:37 +01:00
Dries Peeters
7b03abd9d4 Merge branch 'develop' of https://github.com/drytrix/TimeTracker into develop 2025-11-12 09:36:47 +01:00
Dries Peeters
f8b7afa6c2 Update test_timezone.py 2025-11-12 09:36:44 +01:00
Dries Peeters
99ce155dea Merge pull request #239 from DRYTRIX/Feat-Polishing
Improve navigation and UX for production readiness
2025-11-12 09:02:44 +01:00
Dries Peeters
1e7f1d211a Improve navigation and UX for production readiness
This commit implements several UX improvements based on user feedback
to make the application more production-ready:

Navigation improvements:
- Add Email Configuration link to Admin side menu for easier access
- Move Time Entry Templates from Work menu to Admin section
- Fix menu dropdown state so Time Entry Templates opens Admin menu

Clickable listings for better navigation:
- Make project names clickable in project list view
- Make client names clickable in project list view
- Make task names clickable in task list view
- Make project names clickable in task list view
- Make client names clickable in client list view
- Add mailto: links for client email addresses in list and detail views
- Make project names clickable in client detail view

Kanban board improvements:
- Support more columns on wider screens (up to 6 columns on 2xl screens)
- Change from fixed 4 columns to responsive: lg:4, xl:5, 2xl:6

Dark mode fixes:
- Fix black calendar/time icons in dark mode by adding proper CSS rules
- Add dark mode color classes to calendar icons
- Ensure icons are visible and properly colored in dark theme

These changes improve discoverability, reduce clicks, and enhance the
overall user experience, especially for power users with wide screens.
2025-11-12 08:59:47 +01:00
Dries Peeters
d3f6a792dd Add prepaid-form parsing, tame console noise, and fix invoice UI
parse prepaid hour/reset fields on client edit/create; guard invalid values with new route tests
suppress benign ResizeObserver warnings globally and load handler on standalone pages
raise invoice actions dropdown as a floating menu so it isn’t clipped or scroll-locking
2025-11-12 08:15:04 +01:00
Dries Peeters
14ae197266 Improve timezone handling for system and personal preferences
- share a centralized timezone list across admin and user settings
- allow admins to pick from the same list when setting the system default
- let users clear their personal override to fall back to the global default
- add regression tests covering the new helper and reset path
2025-11-11 14:04:39 +01:00
Dries Peeters
fd92ab7d3e Add upcoming deadlines API for smart notifications 2025-11-11 13:20:12 +01:00
Dries Peeters
d022aa3cbf Fix PDF layout editor canvas scaling and compression issue
The PDF layout editor was displaying the canvas at actual page dimensions (595x842px for A4) without scaling to fit the container, causing the canvas to appear compressed and making it difficult to position elements accurately. When generating PDFs, fields would appear compressed in a small space instead of utilizing the full page width.

Changes:

- Add auto-fit scaling function that calculates optimal scale to fit canvas within container while maintaining aspect ratio

- Center canvas in container using flexbox CSS

- Update zoom controls to work with base fit scale (zoom applies on top of auto-fit)

- Ensure saved designs are properly refitted when loaded

- Add window resize handler to refit canvas on container size changes

The coordinate system remains in actual page dimensions (72 DPI), ensuring that elements positioned in the editor match their positions in generated PDFs. The visual representation is now properly scaled to fit the container, making the editor more user-friendly while maintaining accurate PDF generation.

Fixes issue where canvas appeared smaller than actual page size, causing compression when generating invoices.
2025-11-06 10:42:01 +01:00
Dries Peeters
b157855781 Fix tasks page showing only 20 tasks when filters are set to 'All'
When no filters are active (status, priority, project, assigned_to, search, or overdue), the tasks page now displays all tasks instead of limiting to 20 per page. When filters are active, pagination remains at 20 items per page for better performance.

This fixes the issue where users expected to see all tasks when filters were set to 'All' but only saw the first 20 tasks.
2025-11-06 10:32:46 +01:00
Dries Peeters
8322c73ddc Update tests 2025-11-05 13:58:38 +01:00
Dries Peeters
628e85a402 Update list.html 2025-11-05 13:27:16 +01:00