Added explicit import for _log_admin_event function which is needed for
customer export/import audit logging. Functions with underscore prefix
are not automatically imported by 'from .routes_shared import *'.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit completes the audit logging expansion by adding comprehensive
logging for critical system operations:
- Settings: Log changes to General, Mail, and Autotask settings with
before/after values (passwords excluded for security)
- Exports: Log customer and jobs exports with format and record counts
- Imports: Log customer and jobs imports with operation statistics
Also updated UI to reflect "System Audit Log" nomenclature instead of
"Admin activity" for better semantic clarity.
All audit events use structured event_type identifiers and JSON details
for easy filtering and analysis.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The table name 'admin_logs' was misleading as it contains both admin actions
and automated system events. Renamed to 'audit_logs' to better reflect its
purpose as a comprehensive audit trail.
Changes:
- Renamed model: AdminLog → AuditLog (with backwards compatibility alias)
- Database migration: Renames admin_logs table to audit_logs (idempotent)
- Updated admin_logging.py: log_admin_event → log_audit_event (with alias)
- Updated imports in routes_core.py and routes_shared.py
- Updated all references to use AuditLog instead of AdminLog
- Backwards compatibility maintained via aliases for smooth transition
This is part 1 of audit logging expansion.
Part 2 will add logging for settings changes and export/import actions.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The filter now accepts both datetime objects and string representations.
This fixes AttributeError when datetime fields are stored/returned as
strings instead of datetime objects from the database.
Changes:
- Added string parsing logic for common datetime formats
- Tries multiple format patterns (ISO, standard, with/without microseconds)
- Returns original string if parsing fails (graceful degradation)
- Maintains full datetime object support
Fixes errors on:
- /customers (autotask_last_sync_at)
- /logging (created_at)
- /admin/all-mail (received_at, parsed_at)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extended both customer and jobs export/import to preserve Autotask
company mappings during data migration and system reset workflows.
Changes:
- Customer export (CSV): Added autotask_company_id and autotask_company_name columns
- Customer import (CSV): Reads and applies Autotask mapping fields, resets sync status
- Jobs export (JSON): Includes Autotask fields in customers array
- Jobs import (JSON): Processes customers array with Autotask mappings before jobs
- Backwards compatible: Old exports without Autotask fields continue to work
- Import feedback: Shows both created and updated customer counts
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Split Autotask settings into two separate forms with dedicated save
buttons and field validation:
1. Autotask Settings form:
- Save button inside card for better UX
- Required fields: Environment, Username, Password (if not set),
Tracking Identifier, Base URL
- Red asterisks indicate required fields
2. Ticket Defaults form:
- Separate save button inside card
- Required fields: Queue, Ticket Source, Status, Priority Warning,
Priority Error
- Prevents saving incomplete configurations
Benefits:
- Clear visual separation of concerns
- Prevents accidental saving of empty values
- HTML5 validation ensures all required fields are filled
- Better user experience with focused save actions
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enhanced save logic to protect against losing the default ticket
status value when saving settings with an empty dropdown:
- Only update to new value if a status is actually selected
- Only allow clearing if reference data is loaded (dropdown has options)
- Preserve existing value if dropdown is empty (no reference data)
This fixes the issue where saving settings before reference data
loaded would overwrite the previously configured default status
with NULL, causing "Create Autotask ticket" to fail with error
about missing default status.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed issue where Default Ticket Status dropdown was empty when
opening the settings page. Now automatically loads reference data
(queues, sources, statuses, priorities) when:
- Autotask integration is enabled
- API credentials are configured
- Reference data cache is empty
This eliminates the need to manually click "Refresh reference data"
before being able to select a default ticket status.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added customer active status filtering to prevent jobs from deleted
(inactive) customers from appearing in the UI alongside existing
archived job filtering.
Changes:
- Daily Jobs: Filter jobs where customer is NULL or active=True
- Run Checks: Filter jobs where customer is NULL or active=True
- Jobs list: Filter jobs where customer is NULL or active=True
This prevents showing jobs with "-" status from archived jobs or
deleted customers on Daily Jobs and Run Checks pages.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit consolidates all development work from the following branch series:
- v20260203-* (13 branches): Initial Autotask integration, graph config UI improvements
- v20260204-* (3 branches): Dashboard redirect setting, additional refinements
- v20260205-* (13 branches): Autotask resolution improvements, changelog restructuring
Key features merged:
- Autotask PSA integration with ticket creation, resolution, and search
- Graph/mail configuration UI improvements with credential testing
- Daily dashboard redirect setting (optional navigation control)
- Changelog restructuring with improved Python structure
- Various bug fixes and UI enhancements
All functionality has been consolidated from the final state of branch
v20260205-13-changelog-python-structure to preserve working features.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added "Open in Autotask" button next to ticket number in Run Checks modal
for quick navigation to the ticket in Autotask PSA.
Changes:
- Enhanced renderAutotaskInfo() function in run_checks.html
- Button appears only when autotask_ticket_id exists
- Opens in new tab with proper Autotask URL format
- Styled as small outline button for compact layout
- URL format: https://ww19.autotask.net/Mvc/ServiceDesk/TicketDetail.mvc?workspace=False&ids[0]={id}&ticketId={id}
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added comprehensive breakdown of the Sandbox environment indicator feature
including all modified components (database, backend, frontend, CSS) with
specific technical details for better documentation and understanding.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit adds a new setting that displays a visual "SANDBOX" banner
when the environment is marked as development or sandbox.
Changes:
- Add is_sandbox_environment boolean column to SystemSettings model
- Add database migration for automatic schema update
- Add Environment section in Settings > General with toggle switch
- Create sandbox.css with diagonal banner styling (non-interactive)
- Inject system_settings into all template contexts
- Add sandbox banner to base.html layout
- Update changelog with feature description
The banner appears as a red diagonal ribbon in the top-left corner and
uses pointer-events: none to remain non-interactive while keeping
underlying elements clickable.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added ellipsis-field class to both "Overall remark" and "Remark" fields in
the Run Checks modal. This prevents long text from pushing action buttons
(like Autotask ticket creation) out of view. Users can click the field to
expand/collapse the full text.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The button in the "Link existing Autotask ticket" modal performed a search
operation but was labeled "Refresh", which was confusing. Renamed to "Search"
to accurately reflect its functionality.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>