Commit Graph

6 Commits

Author SHA1 Message Date
Dries Peeters b4486a627f fix: CI tests, code quality, and duplicate DB indexes
- Webhook models: remove duplicate index definitions so db.create_all()
  no longer raises 'index already exists' (columns already have index=True)
- ImportService: fix circular import by late-importing ClientService,
  ProjectService, TimeTrackingService in __init__
- reports: fix F823 by renaming unpack variable _ to _entry_count to avoid
  shadowing gettext _ in export_task_excel()
- Code quality: add .flake8 with extend-ignore so flake8 CI passes;
  simplify pyproject.toml isort config (drop unsupported options)
- Format: run black and isort on app/
- tests: restore minimal app fixture in test_import_export_models
2026-03-15 10:51:52 +01:00
Dries Peeters eeb3aeddf2 Fix BuildError when payment_gateways blueprint is not registered
Add has_endpoint() helper to check if a Flask endpoint exists before
rendering navigation links. When stripe is not installed, the
payment_gateways blueprint fails to register but is_module_enabled()
can still return true, causing url_for('payment_gateways.list_gateways')
to raise BuildError when rendering base.html.

Only show the Payment Gateways nav link when the endpoint is actually
registered. This fixes inventory route tests that failed when following
redirects to the movements list page in environments without stripe.

Related to issue #385 (stock item devaluation).
2026-02-16 06:58:19 +01:00
Dries Peeters 23d4482290 fix(modules): return JSON for API when module disabled or unauthenticated
When module_enabled decorator blocks access, detect JSON/AJAX requests and return 401/403 with JSON body instead of redirect or HTML abort, so API and SPA clients get proper error responses.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-04 22:10:27 +01:00
Dries Peeters 3c01fb34c8 feat(modules): lock client selection and make Clients admin-only
- Add settings.locked_client_id and admin UI to select locked client
- Allow disabling Clients for non-admins while keeping admin access
- Gate Clients UI routes and API endpoints when module is disabled
- Auto-select and enforce the locked client across filters and form submissions

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-02 19:20:48 +01:00
Dries Peeters 3b6bcc890b fix(nav): hide sidebar folder when all modules in category are disabled
Add has_enabled_modules(category) helper and wrap Finance & Expenses
folder so it only renders when at least one FINANCE module is enabled.
Fixes empty folder visible after disabling all modules in a category.

Closes #481

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-02 17:58:55 +01:00
Dries Peeters 083dd9f1f2 feat: Implement comprehensive module system with visibility controls
- Add centralized module registry system (ModuleRegistry) for managing
  module metadata, dependencies, and visibility across the application
- Create module helper utilities with decorators (@module_enabled) and
  helper functions for route protection and template access
- Add database migration (092) to add missing module visibility flags
  to settings and users tables for granular control
- Extend Settings and User models with additional module visibility
  flags for CRM, Finance, Tools, and Advanced features
- Implement admin module management UI for system-wide module
  enable/disable controls
- Add module checks to routes (calendar, contacts, deals, expenses,
  invoices, leads, custom_reports) to enforce visibility rules
- Update scheduled report service and report templates to respect
  module visibility settings
- Bump version to 4.8.0 in setup.py
- Add comprehensive documentation for module integration planning
  and implementation analysis
2025-12-29 14:13:32 +01:00