diff --git a/individual/gql_mutations.py b/individual/gql_mutations.py index d2a90be..4b1d976 100644 --- a/individual/gql_mutations.py +++ b/individual/gql_mutations.py @@ -13,6 +13,7 @@ from individual.services import IndividualService, GroupService, GroupIndividualService, \ CreateGroupAndMoveIndividualService from location.models import Location, LocationManager +from social_protection.apps import SocialProtectionConfig class CreateIndividualInputType(OpenIMISMutation.Input): @@ -30,6 +31,7 @@ class UpdateIndividualInputType(CreateIndividualInputType): RoleEnum = graphene.Enum.from_enum(GroupIndividual.Role) RecipientTypeEnum = graphene.Enum.from_enum(GroupIndividual.RecipientType) +DEFAULT_BENEFICIARY_STATUS = SocialProtectionConfig.default_beneficiary_status class CreateGroupIndividualInputType(OpenIMISMutation.Input): group_id = graphene.UUID(required=False) @@ -571,7 +573,8 @@ def _mutate(cls, user, **data): data.pop('client_mutation_label') custom_filters = data.pop('custom_filters', None) benefit_plan_id = data.pop('benefit_plan_id', None) - status = data.pop('status', "ACTIVE") + # TODO check consistency of default status + status = data.pop('status', DEFAULT_BENEFICIARY_STATUS) service = IndividualService(user) service.select_individuals_to_benefit_plan( custom_filters, @@ -605,7 +608,7 @@ def _mutate(cls, user, **data): data.pop('client_mutation_label') custom_filters = data.pop('custom_filters', None) benefit_plan_id = data.pop('benefit_plan_id', None) - status = data.pop('status', "ACTIVE") + status = data.pop('status', DEFAULT_BENEFICIARY_STATUS) service = GroupService(user) service.select_groups_to_benefit_plan( custom_filters, diff --git a/individual/schema.py b/individual/schema.py index f5e4438..4d33bbb 100644 --- a/individual/schema.py +++ b/individual/schema.py @@ -26,6 +26,7 @@ from individual.models import Individual, IndividualDataSource, Group, \ GroupIndividual, IndividualDataSourceUpload, IndividualDataUploadRecords, GroupDataSource from individual.services import IndividualService, GroupService +from social_protection.apps import SocialProtectionConfig from location.apps import LocationConfig @@ -39,6 +40,7 @@ def patch_details(data_df: pd.DataFrame): return df_final return data_df +DEFAULT_BENEFICIARY_STATUS = SocialProtectionConfig.default_beneficiary_status class Query(ExportableQueryMixin, graphene.ObjectType): export_patches = { @@ -224,7 +226,7 @@ def resolve_individual_enrollment_summary(self, info, **kwargs): service = IndividualService(user) custom_filters = kwargs.get("customFilters", None) benefit_plan_id = kwargs.get("benefitPlanId", None) - status = kwargs.get("status", "ACTIVE") + status = kwargs.get("status", DEFAULT_BENEFICIARY_STATUS) enrollment_checks = service.run_enrollment_checks( custom_filters, @@ -420,7 +422,7 @@ def resolve_group_enrollment_summary(self, info, **kwargs): service = GroupService(user) custom_filters = kwargs.get("customFilters", None) benefit_plan_id = kwargs.get("benefitPlanId", None) - status = kwargs.get("status", "ACTIVE") + status = kwargs.get("status", DEFAULT_BENEFICIARY_STATUS) enrollment_checks = service.run_enrollment_checks( custom_filters,