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:
32
check_orphaned_templates.py
Normal file
32
check_orphaned_templates.py
Normal 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}')
|
||||
Reference in New Issue
Block a user