Fix admin API gaps for users, exchange checks, and parser logs
This commit is contained in:
@@ -29,6 +29,27 @@ class ExchangeConnectionService:
|
||||
"parsers.FinancialReportLine",
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def test_connection_payload(cls, **payload) -> dict[str, str]:
|
||||
"""Проверить подключение и структуру без сохранения в БД."""
|
||||
connection = ExchangeConnection(is_active=False, **payload)
|
||||
alias = cls.test_connection(connection)
|
||||
cls.validate_target_structure(
|
||||
connection=connection,
|
||||
alias=alias,
|
||||
schema_name=connection.schema_name,
|
||||
)
|
||||
|
||||
with suppress(Exception):
|
||||
connections[alias].close()
|
||||
with suppress(Exception):
|
||||
connections.databases.pop(alias, None)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"message": "Подключение и структура целевой БД валидны.",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@transaction.atomic
|
||||
def create_active_connection_and_prepare(cls, **payload) -> ExchangeConnection:
|
||||
@@ -456,4 +477,7 @@ class ExchangeConnectionService:
|
||||
) -> None:
|
||||
connection.last_checked_at = timezone.now()
|
||||
connection.last_error = error_message
|
||||
connection.save(update_fields=["last_checked_at", "last_error", "updated_at"])
|
||||
if connection.pk:
|
||||
connection.save(
|
||||
update_fields=["last_checked_at", "last_error", "updated_at"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user