feat: use authoritative organization directory
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Import the authoritative organizations directory."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from apps.core.management.commands.base import BaseAppCommand
|
||||
|
||||
from organizations.directory_import import OrganizationDirectoryImportService
|
||||
|
||||
|
||||
class Command(BaseAppCommand):
|
||||
"""Import organizations from the authoritative XLSX file."""
|
||||
|
||||
help = "Импортирует справочник organizations.Organization из перечня XLSX"
|
||||
use_transaction = False
|
||||
|
||||
def add_arguments(self, parser) -> None:
|
||||
super().add_arguments(parser)
|
||||
parser.add_argument("path", help="Путь к файлу перечня организаций XLSX.")
|
||||
|
||||
def execute_command(self, *args, **options) -> str:
|
||||
result = OrganizationDirectoryImportService.import_xlsx(options["path"])
|
||||
rendered = json.dumps(
|
||||
{
|
||||
"scanned": result.scanned,
|
||||
"created": result.created,
|
||||
"updated": result.updated,
|
||||
"skipped": result.skipped,
|
||||
},
|
||||
ensure_ascii=False,
|
||||
sort_keys=True,
|
||||
)
|
||||
self.log_success(rendered)
|
||||
return rendered
|
||||
Reference in New Issue
Block a user