## New Features
### Import/Export System
- Add DataImport and DataExport models for tracking operations
- Implement CSV import for bulk time entry data
- Add support for importing from Toggl and Harvest (placeholder)
- Implement GDPR-compliant full data export (JSON format)
- Add filtered export functionality with date/project filters
- Create backup/restore functionality for database migrations
- Build migration wizard UI for seamless data transitions
- Add comprehensive test coverage (unit and integration tests)
- Create user documentation (IMPORT_EXPORT_GUIDE.md)
### Database Changes
- Add migration 040: Create data_imports and data_exports tables
- Track import/export operations with status, logs, and file paths
- Support automatic file expiration for temporary downloads
## UI/UX Improvements
### Navigation Menu Restructure
- Rename "Work" to "Time Tracking" for clarity
- Rename "Finance" to "Finance & Expenses"
- Add "Tools & Data" submenu with Import/Export and Saved Filters
- Reorganize Time Tracking submenu: prioritize Log Time, add icons to all items
- Expand Finance submenu: add Mileage, Per Diem, and Budget Alerts
- Add icons to all Admin submenu items for better visual scanning
- Fix Weekly Goals not keeping Time Tracking menu open
### Standardized Page Headers
Apply consistent page_header macro across 26+ pages:
- **Time Tracking**: Tasks, Projects, Clients, Kanban, Weekly Goals, Templates, Manual Entry
- **Finance**: Invoices, Payments, Expenses, Mileage, Per Diem, Budget Alerts, Reports
- **Admin**: Dashboard, Users, Roles, Permissions, Settings, API Tokens, Backups, System Info, OIDC
- **Tools**: Import/Export, Saved Filters, Calendar
- **Analytics**: Dashboard
Each page now includes:
- Descriptive icon (Font Awesome)
- Clear title and subtitle
- Breadcrumb navigation
- Consistent action button placement
- Responsive design with dark mode support
## Bug Fixes
### Routing Errors
- Fix endpoint name: `per_diem.list_per_diems` → `per_diem.list_per_diem`
- Fix endpoint name: `reports.index` → `reports.reports`
- Fix endpoint name: `timer.timer` → `timer.manual_entry`
- Add missing route registration for import_export blueprint
### User Experience
- Remove duplicate "Test Configuration" button from OIDC debug page
- Clean up user dropdown menu (remove redundant Import/Export link)
- Improve menu item naming ("Profile" → "My Profile", "Settings" → "My Settings")
## Technical Details
### New Files
- `app/models/import_export.py` - Import/Export models
- `app/utils/data_import.py` - Import business logic
- `app/utils/data_export.py` - Export business logic
- `app/routes/import_export.py` - API endpoints
- `app/templates/import_export/index.html` - User interface
- `tests/test_import_export.py` - Integration tests
- `tests/models/test_import_export_models.py` - Model tests
- `docs/IMPORT_EXPORT_GUIDE.md` - User documentation
- `docs/import_export/README.md` - Quick reference
- `migrations/versions/040_add_import_export_tables.py` - Database migration
### Modified Files
- `app/__init__.py` - Register import_export blueprint
- `app/models/__init__.py` - Export new models
- `app/templates/base.html` - Restructure navigation menu
- 26+ template files - Standardize headers with page_header macro
## Breaking Changes
None. All changes are backward compatible.
## Testing
- All existing tests pass
- New test coverage for import/export functionality
- Manual testing of navigation menu changes
- Verified consistent UI across all updated pages
14 KiB
Import/Export System Guide
Overview
The TimeTracker Import/Export system provides comprehensive functionality for migrating data between time tracking systems, exporting data for GDPR compliance, and creating backups for disaster recovery.
Features
Import Features
- CSV Import: Bulk import time entries from CSV files
- Toggl Track Import: Direct integration with Toggl Track API
- Harvest Import: Direct integration with Harvest API
- Backup Restore: Restore from previous backups (admin only)
- Migration Wizard: Step-by-step import process with preview
Export Features
- GDPR Data Export: Complete export of all user data for compliance
- Filtered Export: Export specific data with custom filters
- Full Backup: Complete database backup (admin only)
- Multiple Formats: JSON, CSV, and ZIP formats supported
User Guide
Accessing Import/Export
Navigate to the Import/Export page:
- Click on your user menu in the top right
- Select "Import/Export" from the dropdown
- Or navigate directly to
/import-export
Import Guide
CSV Import
CSV Format
The CSV file should have the following columns:
project_name,client_name,task_name,start_time,end_time,duration_hours,notes,tags,billable
Project A,Client A,Task 1,2024-01-01 09:00:00,2024-01-01 10:30:00,1.5,Meeting notes,meeting;planning,true
Project B,Client B,,2024-01-01 14:00:00,2024-01-01 16:00:00,2.0,Development work,dev;coding,true
Column Descriptions
| Column | Required | Description |
|---|---|---|
project_name |
Yes | Name of the project |
client_name |
No | Client name (defaults to project name if not provided) |
task_name |
No | Optional task name |
start_time |
Yes | Start time (YYYY-MM-DD HH:MM:SS or ISO format) |
end_time |
No | End time (leave empty if providing duration_hours) |
duration_hours |
No | Duration in hours (alternative to end_time) |
notes |
No | Notes or description |
tags |
No | Comma-separated tags (use semicolon to separate multiple tags) |
billable |
No | true/false (defaults to true) |
Supported Date Formats
YYYY-MM-DD HH:MM:SS(e.g., 2024-01-01 09:00:00)YYYY-MM-DDTHH:MM:SS(ISO format)YYYY-MM-DD(assumes midnight)DD/MM/YYYY HH:MM:SSMM/DD/YYYY HH:MM:SS
Steps to Import CSV
- Download the CSV template: Click "Download Template"
- Fill in your time entries data
- Click "Choose CSV File" and select your file
- The import will start automatically
- Check the Import History section for results
Handling Errors
If some records fail to import:
- Check the Import History for error details
- Common errors include:
- Invalid date formats
- Missing required fields (project_name, start_time)
- Invalid duration values
- Fix the errors in your CSV and re-import
Toggl Track Import
Prerequisites
You'll need:
- Toggl Track API token (find in Profile Settings → API Token)
- Workspace ID (find in workspace settings)
Steps to Import from Toggl
- Click "Import from Toggl"
- Enter your API token
- Enter your Workspace ID
- Select date range for import
- Click "Import"
- Wait for the import to complete
What Gets Imported
- All time entries within the selected date range
- Projects (automatically created if they don't exist)
- Clients (linked to projects)
- Tasks (if present in Toggl)
- Tags
- Notes/descriptions
- Billable status
API Rate Limits
Toggl has rate limits on their API. For large imports:
- Import is done in batches of 50 entries
- Imports may take several minutes for large datasets
- If import fails due to rate limits, wait a few minutes and try again
Harvest Import
Prerequisites
You'll need:
- Harvest Account ID (find in Account Settings)
- Personal Access Token (create in Developers → Personal Access Tokens)
Steps to Import from Harvest
- Click "Import from Harvest"
- Enter your Account ID
- Enter your API Token
- Select date range for import
- Click "Import"
- Wait for the import to complete
What Gets Imported
- All time entries within the selected date range
- Projects (automatically created if they don't exist)
- Clients (linked to projects)
- Tasks (if present in Harvest)
- Notes
- Billable status
- Hours tracked
Notes
- Harvest provides daily totals rather than start/end times
- Imported entries will have a default start time of 12:00 PM on the tracked date
- Duration is preserved accurately
Export Guide
GDPR Data Export
Export all your personal data for compliance with data protection regulations.
What's Included
- User profile information
- All time entries
- Projects you've worked on
- Tasks assigned to you
- Expenses and mileage records
- Comments and notes
- Focus sessions
- Saved filters and preferences
- Calendar events
- Weekly goals
Steps to Export
- Choose export format:
- JSON: Single file with all data in JSON format
- ZIP: Multiple CSV files + JSON file in a ZIP archive
- Click the export button
- Wait for export to complete (usually < 1 minute)
- Click "Download" when ready
- Exports expire after 7 days
Export Formats
JSON Export:
{
"export_info": {
"user_id": 1,
"username": "john.doe",
"export_date": "2024-01-15T10:30:00",
"export_type": "GDPR Full Data Export"
},
"user_profile": {...},
"time_entries": [...],
"projects": [...]
}
ZIP Export:
export.json- Complete data in JSONtime_entries.csv- Time entriesprojects.csv- Projectsexpenses.csv- Expenses- etc.
Filtered Export
Export specific data with custom filters.
Available Filters
- Date Range: Export data within specific dates
- Project: Export only specific project data
- Billable Only: Export only billable entries
- Data Types: Choose what to export (time entries, expenses, etc.)
Steps to Export
- Click "Export with Filters"
- Configure your filters
- Choose export format (JSON or CSV)
- Click "Export"
- Download when ready
Backup & Restore (Admin Only)
Creating Backups
Admins can create full database backups:
- Click "Create Backup"
- Wait for backup to complete
- Download the backup file
- Store securely (backup includes all system data)
What's Included in Backups
- All users
- All projects and clients
- All time entries
- All expenses and related data
- Tasks and comments
- System settings
- Invoices and payments
Restoring from Backup
⚠️ Warning: Restore will overwrite existing data!
- Click "Restore Backup"
- Select backup file (JSON format)
- Confirm restoration
- Wait for restore to complete
- Review Import History for results
Best Practices
- Create backups regularly (daily or weekly)
- Test restore process in non-production environment
- Store backups in multiple locations
- Keep backups for at least 30 days
API Documentation
Authentication
All API endpoints require authentication. Include session cookies or API token in requests.
Import Endpoints
CSV Import
POST /api/import/csv
Content-Type: multipart/form-data
file: <csv_file>
Response:
{
"success": true,
"import_id": 123,
"summary": {
"total": 100,
"successful": 95,
"failed": 5,
"errors": []
}
}
Toggl Import
POST /api/import/toggl
Content-Type: application/json
{
"api_token": "your_api_token",
"workspace_id": "12345",
"start_date": "2024-01-01",
"end_date": "2024-12-31"
}
Harvest Import
POST /api/import/harvest
Content-Type: application/json
{
"account_id": "12345",
"api_token": "your_api_token",
"start_date": "2024-01-01",
"end_date": "2024-12-31"
}
Import Status
GET /api/import/status/<import_id>
Response:
{
"id": 123,
"user": "john.doe",
"import_type": "csv",
"status": "completed",
"total_records": 100,
"successful_records": 95,
"failed_records": 5,
"started_at": "2024-01-15T10:00:00",
"completed_at": "2024-01-15T10:05:00"
}
Import History
GET /api/import/history
Export Endpoints
GDPR Export
POST /api/export/gdpr
Content-Type: application/json
{
"format": "json" // or "zip"
}
Response:
{
"success": true,
"export_id": 456,
"filename": "gdpr_export_john.doe_20240115_103000.json",
"download_url": "/api/export/download/456"
}
Filtered Export
POST /api/export/filtered
Content-Type: application/json
{
"format": "json", // or "csv"
"filters": {
"include_time_entries": true,
"include_projects": false,
"include_expenses": true,
"start_date": "2024-01-01",
"end_date": "2024-12-31",
"project_id": null,
"billable_only": false
}
}
Create Backup (Admin Only)
POST /api/export/backup
Download Export
GET /api/export/download/<export_id>
Returns the export file for download.
Export Status
GET /api/export/status/<export_id>
Export History
GET /api/export/history
Troubleshooting
Import Issues
Problem: CSV import fails with "Invalid date format"
- Solution: Check date format matches supported formats. Use YYYY-MM-DD HH:MM:SS
Problem: "Project name is required" error
- Solution: Ensure every row has a project_name value
Problem: Toggl/Harvest import fails
- Solution:
- Verify API credentials are correct
- Check date range is valid
- Ensure you have access to the workspace/account
Problem: Import stuck in "processing" status
- Solution:
- Wait a few minutes (large imports take time)
- Check Import History for errors
- Try re-importing with smaller date range
Export Issues
Problem: Export download says "expired"
- Solution: Create a new export (exports expire after 7 days)
Problem: Export file is empty
- Solution: Check that you have data in the selected date range/filters
Problem: ZIP export won't extract
- Solution: Ensure download completed fully, try re-downloading
Database Schema
DataImport Model
class DataImport:
id: int
user_id: int
import_type: str # 'csv', 'toggl', 'harvest', 'backup'
source_file: str
status: str # 'pending', 'processing', 'completed', 'failed', 'partial'
total_records: int
successful_records: int
failed_records: int
error_log: str # JSON
import_summary: str # JSON
started_at: datetime
completed_at: datetime
DataExport Model
class DataExport:
id: int
user_id: int
export_type: str # 'full', 'filtered', 'backup', 'gdpr'
export_format: str # 'json', 'csv', 'xlsx', 'zip'
file_path: str
file_size: int
status: str # 'pending', 'processing', 'completed', 'failed'
filters: str # JSON
record_count: int
error_message: str
created_at: datetime
completed_at: datetime
expires_at: datetime
Security & Privacy
Data Protection
- All exports are private to the user who created them
- Exports expire after 7 days
- Export files are stored securely in
/data/uploads/exports - Only authenticated users can access their own exports
Admin Privileges
- Backups require admin privileges
- Admins can see all import/export history
- Backup files contain ALL system data
GDPR Compliance
The GDPR export feature provides:
- Complete data portability
- Machine-readable format (JSON)
- Human-readable format (CSV in ZIP)
- All personal data associated with the user
- Compliance with Article 20 (Right to Data Portability)
Migration Wizard
The Migration Wizard provides a guided experience for importing data from other time trackers.
Step 1: Choose Source
Select your source time tracker:
- Toggl Track
- Harvest
- CSV file
Step 2: Enter Credentials
Provide API credentials for the source system.
Step 3: Preview Data
See a preview of what will be imported:
- Number of entries
- Date range
- Projects and clients
Step 4: Confirm Import
Review and start the import process.
Step 5: Monitor Progress
Watch real-time import progress and see results.
Developer Guide
Adding New Import Sources
To add support for a new time tracker:
- Create import function in
app/utils/data_import.py:
def import_from_new_tracker(user_id, credentials, start_date, end_date, import_record):
"""Import from new time tracker"""
# Fetch data from API
# Transform to TimeTracker format
# Create records in database
# Update import_record progress
pass
- Add route in
app/routes/import_export.py:
@import_export_bp.route('/api/import/new-tracker', methods=['POST'])
@login_required
def import_new_tracker():
# Handle import request
pass
- Add UI in template
app/templates/import_export/index.html
Adding New Export Formats
To support a new export format:
- Add export function in
app/utils/data_export.py - Update export routes to handle new format
- Add format option in UI
FAQ
Q: How long are exports stored? A: Exports are automatically deleted after 7 days.
Q: Can I schedule automatic exports? A: Not currently, but this feature is planned.
Q: What happens to duplicates during import? A: Duplicate entries are imported as separate records. Use the date range and filters carefully.
Q: Can I import from multiple Toggl workspaces? A: Yes, import from each workspace separately.
Q: Are imported entries marked differently?
A: Yes, imported entries have a source field set to 'toggl', 'harvest', 'import', etc.
Q: Can I undo an import? A: No automatic undo, but you can filter by source and manually delete imported entries if needed.
Support
For additional help:
- Check the main README
- Review API documentation
- Report issues on GitHub
- Contact your system administrator
Changelog
Version 1.0 (Initial Release)
- CSV import functionality
- Toggl Track integration
- Harvest integration
- GDPR data export
- Filtered exports
- Backup/restore functionality
- Migration wizard
- Import/export history tracking