From f474c3a949bbd58e26675ed08a7afc35e166c50a Mon Sep 17 00:00:00 2001 From: sniedzielski <52816247+sniedzielski@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:16:20 +0200 Subject: [PATCH] CM-1000: manage new way of enabling/disabling synch (#22) * CM-1000: manage new way of enabling/disabling synch * CM-1000: adjustments --- grievance_social_protection/documents.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/grievance_social_protection/documents.py b/grievance_social_protection/documents.py index 21ad98b..47fa1b3 100644 --- a/grievance_social_protection/documents.py +++ b/grievance_social_protection/documents.py @@ -1,13 +1,19 @@ from django.apps import apps +from django.conf import settings + +is_unit_test_env = getattr(settings, 'IS_UNIT_TEST_ENV', False) # Check if the 'opensearch_reports' app is in INSTALLED_APPS -if 'opensearch_reports' in apps.app_configs: - from django_opensearch_dsl import Document, fields as opensearch_fields +if 'opensearch_reports' in apps.app_configs and not is_unit_test_env: + from opensearch_reports.service import BaseSyncDocument + from django_opensearch_dsl import fields as opensearch_fields from django_opensearch_dsl.registries import registry from grievance_social_protection.models import Ticket @registry.register_document - class TicketDocument(Document): + class TicketDocument(BaseSyncDocument): + DASHBOARD_NAME = 'Grievance' + key = opensearch_fields.KeywordField(), title = opensearch_fields.KeywordField(),