Files
stiftung-management-system/app/stiftung/management/commands/init_config.py
SysAdmin Agent e6f4c5ba1b Generalize email system with invoice workflow and Stiftungsgeschichte category
- Rename DestinataerEmailEingang → EmailEingang with category support
  (destinataer, rechnung, land_pacht, stiftungsgeschichte, allgemein)
- Add invoice capture workflow: create Verwaltungskosten from email,
  link DMS documents as invoice attachments, track payment status
- Add Stiftungsgeschichte email category with auto-detection patterns
  (Ahnenforschung, Genealogie, Chronik, etc.) and DMS integration
- Update poll_emails task with category detection and DMS context mapping
- Show available history documents in Geschichte editor sidebar
- Consolidate DMS views, remove legacy dokument templates
- Update all detail/form templates for DMS document linking
- Add deploy.sh script and streamline compose.yml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 10:17:14 +00:00

107 lines
3.7 KiB
Python

from django.core.management.base import BaseCommand
from stiftung.models import AppConfiguration
class Command(BaseCommand):
help = "Initialize default app configuration settings"
def handle(self, *args, **options):
# E-Mail / IMAP Settings
email_settings = [
{
"key": "imap_host",
"display_name": "IMAP Server",
"description": "Hostname oder IP-Adresse des IMAP-Servers (z.B. mail.example.com)",
"value": "",
"default_value": "",
"setting_type": "text",
"category": "email",
"order": 1,
},
{
"key": "imap_port",
"display_name": "IMAP Port",
"description": "Port des IMAP-Servers (Standard: 993 für SSL, 143 für unverschlüsselt)",
"value": "993",
"default_value": "993",
"setting_type": "number",
"category": "email",
"order": 2,
},
{
"key": "imap_user",
"display_name": "IMAP Benutzername",
"description": "Benutzername / E-Mail-Adresse für die IMAP-Anmeldung",
"value": "",
"default_value": "",
"setting_type": "text",
"category": "email",
"order": 3,
},
{
"key": "imap_password",
"display_name": "IMAP Passwort",
"description": "Passwort für die IMAP-Anmeldung",
"value": "",
"default_value": "",
"setting_type": "password",
"category": "email",
"order": 4,
},
{
"key": "imap_folder",
"display_name": "IMAP Ordner",
"description": "Name des zu überwachenden Postfach-Ordners (Standard: INBOX)",
"value": "INBOX",
"default_value": "INBOX",
"setting_type": "text",
"category": "email",
"order": 5,
},
{
"key": "imap_use_ssl",
"display_name": "SSL/TLS verwenden",
"description": "Sichere Verbindung zum IMAP-Server (empfohlen)",
"value": "True",
"default_value": "True",
"setting_type": "boolean",
"category": "email",
"order": 6,
},
]
all_settings = email_settings
created_count = 0
updated_count = 0
for setting_data in all_settings:
setting, created = AppConfiguration.objects.get_or_create(
key=setting_data["key"], defaults=setting_data
)
if created:
created_count += 1
self.stdout.write(
self.style.SUCCESS(f"Created setting: {setting.display_name}")
)
else:
# Update existing setting with new defaults if needed
if not setting.description:
setting.description = setting_data["description"]
setting.save()
updated_count += 1
self.stdout.write(
self.style.SUCCESS(
f"Configuration initialized successfully! "
f"Created {created_count} new settings, updated {updated_count} existing settings."
)
)
self.stdout.write(
self.style.WARNING(
'You can now manage these settings in the Django Admin under "App Configurations"'
)
)