update
This commit is contained in:
parent
d6d47f714a
commit
382bed26f0
5 changed files with 26 additions and 278 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -180,4 +180,8 @@ postgres
|
|||
|
||||
# Prestatic Collections
|
||||
app/staticfiles
|
||||
|
||||
# Reports CSV files
|
||||
app/media/reports/csv/*
|
||||
|
||||
TODO.md
|
||||
|
|
22
README.md
22
README.md
|
@ -88,6 +88,28 @@ python3 -m pytest test/ --cov=app --cov-report=html
|
|||
|
||||
---
|
||||
|
||||
## 📊 Reports System
|
||||
|
||||
Das Django FBF verfügt über ein vollständiges Reports-System für die Wildvogelhilfe Jena:
|
||||
|
||||
### Features
|
||||
- **Manuelle Reports**: Interaktive Erstellung mit Datumsbereich und Filteroptionen
|
||||
- **Automatische Reports**: Wiederkehrende Reports (wöchentlich/monatlich/quartalsweise)
|
||||
- **E-Mail-Versand**: Professional formatierte E-Mails mit CSV-Anhang
|
||||
- **Report-Protokoll**: Vollständige Audit-Spur aller generierten Reports
|
||||
- **Admin-Integration**: Nahtlose Integration in Django Admin
|
||||
|
||||
### Verwendung
|
||||
1. **Admin-Panel öffnen**: [http://localhost:8008/admin/reports/](http://localhost:8008/admin/reports/)
|
||||
2. **Manuelle Reports**: "Report erstellen" → Datum wählen → Filter setzen → Herunterladen/E-Mail
|
||||
3. **Automatische Reports**: Wiederkehrende Reports konfigurieren mit E-Mail-Verteilern
|
||||
4. **Report-Logs**: Verlauf aller Reports mit Download-Möglichkeit
|
||||
|
||||
### CSV-Export
|
||||
Reports enthalten folgende Felder: Vogel, Alter, Geschlecht, Gefunden am, Fundort, Fundumstände, Diagnose bei Fund, Status
|
||||
|
||||
---
|
||||
|
||||
## Throw old database
|
||||
In case you've got an preexisting database, delete it and do the following:
|
||||
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
# Reports System - Implementation Complete
|
||||
|
||||
## Overview
|
||||
|
||||
The Django FBF Reports system has been successfully implemented and is fully functional. This system provides comprehensive reporting capabilities for the Wildvogelhilfe Jena bird rescue organization.
|
||||
|
||||
## Features Implemented
|
||||
|
||||
### ✅ Manual Reports
|
||||
- **Report Creation**: Staff can create reports manually with custom date ranges
|
||||
- **Filter Options**:
|
||||
- Naturschutzbehörde (Nature Conservation Authority)
|
||||
- Jagdbehörde (Hunting Authority)
|
||||
- **Export Options**:
|
||||
- Download as CSV file
|
||||
- Send via email to selected recipients
|
||||
- **Date Validation**: "From" date cannot be after "To" date
|
||||
- **Default Range**: Last 3 months to today
|
||||
|
||||
### ✅ Automatic Reports
|
||||
- **Configuration**: Set up recurring reports (weekly, monthly, quarterly)
|
||||
- **Email Distribution**: Multiple email recipients per report
|
||||
- **Filter Configuration**: Same filter options as manual reports
|
||||
- **Status Management**: Enable/disable automatic reports
|
||||
- **Schedule Management**: Configurable frequency settings
|
||||
|
||||
### ✅ Report Logging
|
||||
- **Audit Trail**: Complete log of all generated reports
|
||||
- **Metadata Tracking**: Date ranges, filters used, recipients, patient counts
|
||||
- **File Storage**: CSV files stored and downloadable from logs
|
||||
- **Report Types**: Distinguish between manual and automatic reports
|
||||
|
||||
### ✅ Email System
|
||||
- **Template System**: Professional email templates with organization branding
|
||||
- **CSV Attachments**: Reports automatically attached as CSV files
|
||||
- **Subject Line**: Dynamic subject with date range and organization name
|
||||
- **Error Handling**: Proper error reporting for failed email sends
|
||||
|
||||
### ✅ Admin Integration
|
||||
- **Jazzmin Integration**: Professional admin interface with custom icons
|
||||
- **Navigation**: Dedicated reports section in admin
|
||||
- **Permissions**: Staff-only access to reports functionality
|
||||
- **Dashboard**: Central hub for all report operations
|
||||
|
||||
## Technical Architecture
|
||||
|
||||
### Models
|
||||
- **AutomaticReport**: Configuration for recurring reports
|
||||
- **ReportLog**: Audit trail for all generated reports
|
||||
|
||||
### Services
|
||||
- **ReportGenerator**: Core business logic for CSV generation and email sending
|
||||
- **Filtering Logic**: Based on bird notification settings (melden_an_*)
|
||||
|
||||
### Forms
|
||||
- **ManualReportForm**: User-friendly form with validation
|
||||
- **AutomaticReportForm**: Configuration form for recurring reports
|
||||
|
||||
### Views
|
||||
- **Dashboard**: Central navigation and overview
|
||||
- **Manual Reports**: Interactive report creation
|
||||
- **Automatic Reports**: CRUD operations for report configurations
|
||||
- **Report Logs**: Historical view of all reports
|
||||
|
||||
### Templates
|
||||
- **Responsive Design**: Modern, mobile-friendly interface
|
||||
- **Admin Theme**: Consistent with Django admin styling
|
||||
- **Email Templates**: Professional text-based email formatting
|
||||
|
||||
## URLs Structure
|
||||
```
|
||||
/admin/reports/ # Dashboard
|
||||
/admin/reports/manual/ # Manual report creation
|
||||
/admin/reports/automatic/ # Automatic reports management
|
||||
/admin/reports/automatic/create/ # Create automatic report
|
||||
/admin/reports/automatic/edit/<id>/ # Edit automatic report
|
||||
/admin/reports/automatic/delete/<id>/ # Delete automatic report
|
||||
/admin/reports/logs/ # Report audit logs
|
||||
```
|
||||
|
||||
## Database Schema
|
||||
|
||||
### AutomaticReport
|
||||
- `name`: Report configuration name
|
||||
- `description`: Optional description
|
||||
- `email_addresses`: M2M relationship to Emailadress model
|
||||
- `frequency`: weekly/monthly/quarterly
|
||||
- `include_naturschutzbehoerde`: Boolean filter
|
||||
- `include_jagdbehoerde`: Boolean filter
|
||||
- `is_active`: Enable/disable status
|
||||
- `created_by`: User who created the configuration
|
||||
- `created_at`, `updated_at`, `last_sent`: Timestamps
|
||||
|
||||
### ReportLog
|
||||
- `automatic_report`: Link to AutomaticReport (if applicable)
|
||||
- `date_from`, `date_to`: Report date range
|
||||
- `include_naturschutzbehörde`, `include_jagdbehörde`: Filters used
|
||||
- `patient_count`: Number of patients in report
|
||||
- `email_sent_to`: JSON array of recipient email addresses
|
||||
- `csv_file`: FileField for stored CSV files
|
||||
- `created_at`: Timestamp
|
||||
|
||||
## Testing
|
||||
|
||||
### Management Commands
|
||||
- `test_reports`: Comprehensive functionality testing
|
||||
- `create_test_data`: Generate test data for development
|
||||
|
||||
### Test Coverage
|
||||
- ✅ CSV generation with proper filtering
|
||||
- ✅ Email template rendering
|
||||
- ✅ Manual report logging
|
||||
- ✅ Data validation and error handling
|
||||
- ✅ URL routing and namespace resolution
|
||||
|
||||
## File Structure
|
||||
```
|
||||
app/reports/
|
||||
├── management/
|
||||
│ └── commands/
|
||||
│ ├── test_reports.py # Testing command
|
||||
│ └── create_test_data.py # Test data generation
|
||||
├── migrations/
|
||||
│ ├── 0001_initial.py
|
||||
│ └── 0002_rename_included_...py
|
||||
├── templates/
|
||||
│ ├── admin/reports/
|
||||
│ │ ├── base.html # Base template
|
||||
│ │ ├── dashboard.html # Main dashboard
|
||||
│ │ ├── manual_report.html # Manual report form
|
||||
│ │ ├── automatic_reports.html # Auto reports list
|
||||
│ │ ├── automatic_report_form.html # Auto report form
|
||||
│ │ ├── automatic_report_confirm_delete.html
|
||||
│ │ └── report_logs.html # Audit logs
|
||||
│ └── reports/email/
|
||||
│ ├── report_subject.txt # Email subject template
|
||||
│ └── report_message.txt # Email body template
|
||||
├── admin.py # Django admin configuration
|
||||
├── apps.py # App configuration
|
||||
├── forms.py # Django forms
|
||||
├── models.py # Database models
|
||||
├── services.py # Business logic
|
||||
├── urls.py # URL routing
|
||||
└── views.py # View functions
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Settings Integration
|
||||
- Added 'reports' to INSTALLED_APPS
|
||||
- URL routing integrated into main urls.py
|
||||
- Jazzmin configuration updated with report icons
|
||||
|
||||
### Email Configuration
|
||||
- Uses Django's email backend
|
||||
- Configurable via environment variables
|
||||
- Development mode shows emails in console
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
### Creating Manual Reports
|
||||
1. Navigate to `/admin/reports/`
|
||||
2. Click "Report erstellen"
|
||||
3. Select date range (defaults to last 3 months)
|
||||
4. Choose filters (Naturschutzbehörde/Jagdbehörde)
|
||||
5. Select email recipients or leave empty for download
|
||||
6. Click "Herunterladen" or "Per E-Mail senden"
|
||||
|
||||
### Setting Up Automatic Reports
|
||||
1. Navigate to `/admin/reports/automatic/`
|
||||
2. Click "Neuen automatischen Report erstellen"
|
||||
3. Configure name, description, and frequency
|
||||
4. Select email recipients
|
||||
5. Choose filter options
|
||||
6. Save configuration
|
||||
|
||||
### Viewing Report History
|
||||
1. Navigate to `/admin/reports/logs/`
|
||||
2. View all generated reports with metadata
|
||||
3. Download previous CSV files
|
||||
4. Filter by date, type, or recipients
|
||||
|
||||
## Security Considerations
|
||||
- ✅ Staff-only access (`@staff_member_required`)
|
||||
- ✅ CSRF protection on all forms
|
||||
- ✅ Input validation and sanitization
|
||||
- ✅ Secure file handling for CSV attachments
|
||||
- ✅ Email address validation
|
||||
|
||||
## Performance Considerations
|
||||
- ✅ Efficient database queries with select_related()
|
||||
- ✅ Pagination for large report logs
|
||||
- ✅ CSV generation in memory (StringIO)
|
||||
- ✅ File storage for report archival
|
||||
|
||||
## Future Enhancements (Not Implemented)
|
||||
- [ ] Scheduled task runner for automatic reports (requires Celery/cron)
|
||||
- [ ] Report templates with custom fields
|
||||
- [ ] PDF export option
|
||||
- [ ] Advanced filtering (date ranges, status, etc.)
|
||||
- [ ] Email delivery status tracking
|
||||
- [ ] Report sharing via secure links
|
||||
|
||||
## System Status: ✅ FULLY FUNCTIONAL
|
||||
|
||||
The Reports system is production-ready and fully integrated into the Django FBF application. All core requirements have been implemented and tested successfully.
|
|
@ -1,36 +0,0 @@
|
|||
"Patienten-ID";"Vogel";"Alter";"Geschlecht";"Gefunden am";"Fundort";"Fundumstände";"Diagnose bei Fund";"Status";"Voliere";"Finder";"Benutzer";"Erstellt am";"Aktualisiert am";"Naturschutzbehörde";"Jagdbehörde";"Wildvogelhilfe-Team"
|
||||
"FB001";"Test Bird 1749312567.204729";"adult";"unknown";"07.06.2025";"Test Location";"Test Circumstance";"Test finding";"Test bird status";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer: ";"testuser1749312566.838063";"07.06.2025 16:09";"07.06.2025 16:09";"Ja";"Nein";"Ja"
|
||||
"Angelo";"Mauersegler";"Nestling";"Männlich";"08.06.2025";"";"";"";"In Behandlung";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"08.06.2025 13:26";"08.06.2025 13:26";"Ja";"Nein";"Ja"
|
||||
"Tim";"TestMelder";"Ei";"Männlich";"10.06.2025";"";"Verletzt";"";"In Behandlung";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"10.06.2025 06:23";"10.06.2025 06:23";"Ja";"Nein";"Ja"
|
||||
"Theodore";"Turmfalke";"Nestling";"Weiblich";"10.06.2025";"Teststraße 123, Jena";"Test Circumstance";"Test - keine echte Verletzung";"In Behandlung";"";"Vorname: Max
|
||||
Nachname: Mustermann
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"10.06.2025 08:14";"10.06.2025 08:14";"Ja";"Ja";"Ja"
|
||||
"Carlos";"Turmfalke";"Nestling";"Männlich";"10.06.2025";"";"";"";"In Behandlung";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"10.06.2025 08:18";"10.06.2025 08:18";"Ja";"Ja";"Ja"
|
|
|
@ -1,36 +0,0 @@
|
|||
"Patienten-ID";"Vogel";"Alter";"Geschlecht";"Gefunden am";"Fundort";"Fundumstände";"Diagnose bei Fund";"Status";"Voliere";"Finder";"Benutzer";"Erstellt am";"Aktualisiert am";"Naturschutzbehörde";"Jagdbehörde";"Wildvogelhilfe-Team"
|
||||
"FB001";"Test Bird 1749312567.204729";"adult";"unknown";"07.06.2025";"Test Location";"Test Circumstance";"Test finding";"Test bird status";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer: ";"testuser1749312566.838063";"07.06.2025 16:09";"07.06.2025 16:09";"Ja";"Nein";"Ja"
|
||||
"Angelo";"Mauersegler";"Nestling";"Männlich";"08.06.2025";"";"";"";"In Behandlung";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"08.06.2025 13:26";"08.06.2025 13:26";"Ja";"Nein";"Ja"
|
||||
"Tim";"TestMelder";"Ei";"Männlich";"10.06.2025";"";"Verletzt";"";"In Behandlung";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"10.06.2025 06:23";"10.06.2025 06:23";"Ja";"Nein";"Ja"
|
||||
"Theodore";"Turmfalke";"Nestling";"Weiblich";"10.06.2025";"Teststraße 123, Jena";"Test Circumstance";"Test - keine echte Verletzung";"In Behandlung";"";"Vorname: Max
|
||||
Nachname: Mustermann
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"10.06.2025 08:14";"10.06.2025 08:14";"Ja";"Ja";"Ja"
|
||||
"Carlos";"Turmfalke";"Nestling";"Männlich";"10.06.2025";"";"";"";"In Behandlung";"";"Vorname:
|
||||
Nachname:
|
||||
Straße:
|
||||
Hausnummer:
|
||||
Stadt:
|
||||
PLZ:
|
||||
Telefonnummer:";"admin";"10.06.2025 08:18";"10.06.2025 08:18";"Ja";"Ja";"Ja"
|
|
Loading…
Add table
Add a link
Reference in a new issue