Skip to content

Commit

Permalink
Added G2P Import DCI API module.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumar-02 committed Feb 9, 2024
1 parent 78a86ca commit 4fbe5ce
Show file tree
Hide file tree
Showing 28 changed files with 1,616 additions and 0 deletions.
Empty file added g2p_import_dci_api/README.rst
Empty file.
1 change: 1 addition & 0 deletions g2p_import_dci_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
26 changes: 26 additions & 0 deletions g2p_import_dci_api/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": """OpenG2P Import: DCI API""",
"summary": """RESTful API routes for OpenG2P""",
"category": "",
"version": "15.0.1.1.0",
"author": "OpenG2P",
"development_status": "Alpha",
"external_dependencies": {"python": ["PyLD", "pyjwt>=2.4.0"]},
"website": "https://openg2p.org",
"license": "LGPL-3",
"depends": [
"base",
"g2p_programs",
"g2p_registry_base",
"g2p_registry_individual",
"spp_registry_data_source",
],
"data": [
"security/fetch_social_registry_security.xml",
"security/ir.model.access.csv",
"views/fetch_social_registry_beneficiary_views.xml",
],
"application": True,
"auto_install": False,
"installable": True,
}
8 changes: 8 additions & 0 deletions g2p_import_dci_api/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from . import individual
from . import eligibility_manager
from . import constants
from . import fetch_social_registry_beneficiary
from . import group
from . import group_membership
from . import imported_individuals
from . import res_partner
27 changes: 27 additions & 0 deletions g2p_import_dci_api/models/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
PREDICATE = "predicate"

GRAPHQL = "graphql"

OPERATION_MAPPING = {
"=": "eq",
">": "gt",
"<": "lt",
">=": "ge",
"<=": "le",
"in": "in",
}

FIELD_MAPPING = {
"birthdate": "birthdate",
"location": "birthplace",
}

DATA_SOURCE_NAME = "Social Registry"
DATA_SOURCE_SEARCH_PATH_NAME = "Registry Sync Search"
DATA_SOURCE_AUTH_PATH_NAME = "Authentication"

DEFAULT_YEAR = 2023
DEFAULT_MONTH = 11
DEFAULT_DAY = 15

REQUEST_TIMEOUT = 60
23 changes: 23 additions & 0 deletions g2p_import_dci_api/models/eligibility_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging

from odoo import api, fields, models

from ..models.constants import DATA_SOURCE_NAME
from ..tools import field_onchange

_logger = logging.getLogger(__name__)


class G2PDefaultEligibilityManager(models.Model):
_inherit = "g2p.program_membership.manager.default"

data_source_id = fields.Many2one("spp.data.source")
is_social_registry_data_source = fields.Boolean()

@api.onchange("data_source_id")
def onchange_data_source_id(self):
field_onchange(self, "data_source_id.name", "data_source_id.name")
if self.data_source_id and self.data_source_id.name == DATA_SOURCE_NAME:
self.is_social_registry_data_source = True
else:
self.is_social_registry_data_source = False
Loading

0 comments on commit 4fbe5ce

Please sign in to comment.