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 python3
"""
Script to replace all remaining legacy Verpachtung references with LandVerpachtung
"""
import re
def replace_verpachtung_references():
with open('app/stiftung/views.py', 'r', encoding='utf-8') as f:
content = f.read()
# Replace Verpachtung.objects with LandVerpachtung.objects
content = re.sub(r'\bVerpachtung\.objects\b', 'LandVerpachtung.objects', content)
# Replace legacy field names with new ones
content = re.sub(r'pachtzins_jaehrlich', 'pachtzins_pauschal', content)
# Replace legacy field references in aggregates
content = re.sub(r"Sum\('verpachtung__pachtzins_jaehrlich'\)", "Sum('landverpachtung__pachtzins_pauschal')", content)
content = re.sub(r"Sum\('verpachtung__verpachtete_flaeche'\)", "Sum('landverpachtung__verpachtete_flaeche')", content)
# Update related name references
content = re.sub(r"verpachtung_set", "landverpachtung_set", content)
content = re.sub(r"verpachtung_id", "land_verpachtung_id", content)
with open('app/stiftung/views.py', 'w', encoding='utf-8') as f:
f.write(content)
print("Updated all legacy Verpachtung references to use LandVerpachtung")
if __name__ == "__main__":
replace_verpachtung_references()