Skip to content

Commit

Permalink
Merge pull request #94 from openimis/feature/CM-1000
Browse files Browse the repository at this point in the history
CM-1000: added changes with synch enabled/disabled - opensearch
  • Loading branch information
jdolkowski authored Sep 20, 2024
2 parents fa02b08 + 0eb5c50 commit 3bae0d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions social_protection/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
],
"social_protection_masking_enabled": True,
"enable_python_workflows": True,
"opensearch_synch": False,
}


Expand Down Expand Up @@ -91,7 +90,6 @@ class SocialProtectionConfig(AppConfig):

enable_python_workflows = None
enable_maker_checker_logic_enrollment = None
opensearch_synch = None
beneficiary_mask_fields = None
group_beneficiary_mask_fields = None
social_protection_masking_enabled = None
Expand Down
12 changes: 8 additions & 4 deletions social_protection/documents.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from django.apps import apps
from django.conf import settings

from social_protection.apps import SocialProtectionConfig
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 and SocialProtectionConfig.opensearch_synch:
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 social_protection.models import Beneficiary, BenefitPlan
from individual.models import Individual

@registry.register_document
class BeneficiaryDocument(Document):
class BeneficiaryDocument(BaseSyncDocument):
DASHBOARD_NAME = 'Beneficiary'

benefit_plan = opensearch_fields.ObjectField(properties={
'code': opensearch_fields.KeywordField(),
'name': opensearch_fields.KeywordField(),
Expand Down

0 comments on commit 3bae0d0

Please sign in to comment.