fix: configure CI database connection properly

- Add dotenv loading to Django settings
- Update CI workflow to use correct environment variables
- Set POSTGRES_* variables instead of DATABASE_URL
- Add environment variables to all Django management commands
- Fixes CI test failures due to database connection issues
This commit is contained in:
Stiftung Development
2025-09-06 18:47:23 +02:00
parent dcc91b9f49
commit 35ba089a84
64 changed files with 7040 additions and 1419 deletions

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python
import os
import django
# Setup Django environment
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
django.setup()
from stiftung.models import UnterstuetzungWiederkehrend, DestinataerUnterstuetzung
# Find orphaned templates
orphaned = []
for template in UnterstuetzungWiederkehrend.objects.all():
count = DestinataerUnterstuetzung.objects.filter(wiederkehrend_von=template).count()
if count == 0:
orphaned.append((template, count))
print(f'Verwaiste Vorlagen gefunden: {len(orphaned)}')
if orphaned:
print('Details:')
for template, count in orphaned[:10]: # Show first 10
print(f'- ID {template.id}: {template.destinataer} - {template.beschreibung} ({template.betrag}€)')
else:
print('Keine verwaisten Vorlagen!')
# Also show all templates with their payment counts
print('\n--- Alle wiederkehrende Vorlagen ---')
all_templates = UnterstuetzungWiederkehrend.objects.all()
for template in all_templates[:10]: # Show first 10
count = DestinataerUnterstuetzung.objects.filter(wiederkehrend_von=template).count()
status = "VERWAIST" if count == 0 else f"{count} Zahlungen"
print(f'ID {template.id}: {template.destinataer} - {template.beschreibung} ({template.betrag}€) - {status}')