Files
vergabe-teilnahme/vergabe_teilnahme/apps/aufgaben/issue_backends.py
tegwick 17f511fbcd Rewire issue tracker integration from issue-facade to issue-core
issue-facade was renamed to issue-core. Update the dependency
declaration and the three Python imports it touched. Model field
names (issue_facade_backend, issue_facade_id) and the Django setting
ISSUE_FACADE_LOCAL_DB stay as-is — they are persisted/semantic
identifiers, not part of the package wiring.

All 20 aufgaben tests pass after the rewire.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 22:33:28 +02:00

44 lines
1.0 KiB
Python

from contextlib import contextmanager
from pathlib import Path
@contextmanager
def local_backend():
from django.conf import settings
from issue_core.backends.local import LocalSQLiteBackend
db_path = str(getattr(settings, 'ISSUE_FACADE_LOCAL_DB', '.issue-facade/issues.db'))
Path(db_path).parent.mkdir(parents=True, exist_ok=True)
b = LocalSQLiteBackend()
b.connect({'db_path': db_path})
try:
yield b
finally:
b.disconnect()
@contextmanager
def remote_backend():
"""Yields GiteaBackend wenn konfiguriert, sonst None."""
from django.conf import settings
from issue_core.backends.gitea import GiteaBackend
cfg = getattr(settings, 'ISSUE_FACADE_GITEA', None)
if not cfg:
yield None
return
b = GiteaBackend()
b.connect(cfg)
try:
yield b
finally:
b.disconnect()
def gitea_configured() -> bool:
from django.conf import settings
cfg = getattr(settings, 'ISSUE_FACADE_GITEA', None)
return bool(cfg and cfg.get('token'))