Skip to content

Commit

Permalink
Merge branch 'staging' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola authored Dec 4, 2024
2 parents b2d1f59 + 3dbdc4e commit c7317f8
Show file tree
Hide file tree
Showing 27 changed files with 140 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/frontend/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,9 @@ enum IndividualRoleInHouseholdRole {
enum IndividualSex {
MALE
FEMALE
OTHER
NOT_COLLECTED
NOT_ANSWERED
}

input IndividualUpdateDataObjectType {
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/src/__generated__/graphql.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,15 @@ export const CreateVerificationPlan = ({
choices={[
{ value: 'FEMALE', name: t('Female') },
{ value: 'MALE', name: t('Male') },
{ value: 'OTHER', name: t('Other') },
{
value: 'NOT_COLLECTED',
name: t('Not Collected'),
},
{
value: 'NOT_ANSWERED',
name: t('Not Answered'),
},
]}
component={FormikSelectField}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/components/payments/EditVerificationPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ export const EditVerificationPlan = ({
choices={[
{ value: 'FEMALE', name: t('Female') },
{ value: 'MALE', name: t('Male') },
{ value: 'OTHER', name: t('Other') },
{ value: 'NOT_COLLECTED', name: t('Not Collected') },
{ value: 'NOT_ANSWERED', name: t('Not Answered') },
]}
component={FormikSelectField}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/components/people/PeopleFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ export function PeopleFilter({
>
<MenuItem value="FEMALE">{t('Female')}</MenuItem>
<MenuItem value="MALE">{t('Male')}</MenuItem>
<MenuItem value="OTHER">{t('Other')}</MenuItem>
<MenuItem value="NOT_COLLECTED">{t('Not Collected')}</MenuItem>
<MenuItem value="NOT_ANSWERED">{t('Not Answered')}</MenuItem>
</SelectFilter>
</Grid>
<Grid item xs={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ export const FilterIndividuals: FC<FilterIndividualsProps> = ({
<MenuItem key="female" value="FEMALE">
{t('Female')}
</MenuItem>
<MenuItem key="other" value="OTHER">
{t('Other')}
</MenuItem>
<MenuItem key="not_collected" value="NOT_COLLECTED">
{t('Not Collected')}
</MenuItem>
<MenuItem key="not_answered" value="NOT_ANSWERED">
{t('Not Answered')}
</MenuItem>
</SelectFilter>
</Grid>
<Grid item xs={3}>
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/components/population/IndividualsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export function IndividualsFilter({
>
<MenuItem value="FEMALE">{t('Female')}</MenuItem>
<MenuItem value="MALE">{t('Male')}</MenuItem>
<MenuItem value="OTHER">{t('Other')}</MenuItem>
<MenuItem value="NOT_COLLECTED">{t('Not Collected')}</MenuItem>
<MenuItem value="NOT_ANSWERED">{t('Not Answered')}</MenuItem>
</SelectFilter>
</Grid>
<Grid item xs={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ export const CreateCommunicationPage = (): ReactElement => {
choices={[
{ value: 'FEMALE', name: t('Female') },
{ value: 'MALE', name: t('Male') },
{ value: 'OTHER', name: t('Other') },
{ value: 'NOT_COLLECTED', name: t('Not Collected') },
{ value: 'NOT_ANSWERED', name: t('Not Answered') },
]}
component={FormikSelectField}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ export const CreateSurveyPage = (): ReactElement => {
choices={[
{ value: 'FEMALE', name: t('Female') },
{ value: 'MALE', name: t('Male') },
{ value: 'OTHER', name: t('Other') },
{ value: 'NOT_COLLECTED', name: t('Not Collected') },
{ value: 'NOT_ANSWERED', name: t('Not Answered') },
]}
component={FormikSelectField}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/restgenerated/models/SexEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
export enum SexEnum {
MALE = 'MALE',
FEMALE = 'FEMALE',
OTHER = 'OTHER',
NOT_COLLECTED = 'NOT_COLLECTED',
NOT_ANSWERED = 'NOT_ANSWERED',
}
3 changes: 3 additions & 0 deletions src/frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import {
const Gender = new Map([
['MALE', 'Male'],
['FEMALE', 'Female'],
['OTHER', 'Other'],
['NOT_COLLECTED', 'Not Collected'],
['NOT_ANSWERED', 'Not Answered'],
]);

const IdentificationType = new Map([
Expand Down
1 change: 1 addition & 0 deletions src/hct_mis_api/apps/household/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def calculate_children_fields_for_not_collected_individual_data() -> int:
)

return Household.objects.exclude(collect_individual_data__in=[COLLECT_TYPE_FULL, COLLECT_TYPE_PARTIAL]).update(
# TODO: count differently or add all the fields for the new gender options
children_count=Coalesce("female_age_group_0_5_count", 0)
+ Coalesce("female_age_group_6_11_count", 0)
+ Coalesce("female_age_group_12_17_count", 0)
Expand Down
18 changes: 18 additions & 0 deletions src/hct_mis_api/apps/household/migrations/0004_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2024-11-28 23:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('household', '0003_migration'),
]

operations = [
migrations.AlterField(
model_name='individual',
name='sex',
field=models.CharField(choices=[('MALE', 'Male'), ('FEMALE', 'Female'), ('OTHER', 'Other'), ('NOT_COLLECTED', 'Not collected'), ('NOT_ANSWERED', 'Not answered')], db_index=True, max_length=255),
),
]
7 changes: 6 additions & 1 deletion src/hct_mis_api/apps/household/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@
# INDIVIDUALS
MALE = "MALE"
FEMALE = "FEMALE"
UNKNOWN = "UNKNOWN"
OTHER = "OTHER"
NOT_COLLECTED = "NOT_COLLECTED"
NOT_ANSWERED = "NOT_ANSWERED"

SEX_CHOICE = (
(MALE, _("Male")),
(FEMALE, _("Female")),
(OTHER, _("Other")),
(NOT_COLLECTED, _("Not collected")),
(NOT_ANSWERED, _("Not answered")),
)

SINGLE = "SINGLE"
Expand Down
18 changes: 18 additions & 0 deletions src/hct_mis_api/apps/payment/migrations/0005_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2024-11-28 23:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('payment', '0004_migration'),
]

operations = [
migrations.AlterField(
model_name='paymentverificationplan',
name='sex_filter',
field=models.CharField(blank=True, max_length=255, null=True),
),
]
5 changes: 2 additions & 3 deletions src/hct_mis_api/apps/payment/models/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,15 @@ def update_population_count_fields(self) -> None:
female_children_count=Count("id", distinct=True, filter=Q(birth_date__gt=date18ago, sex=FEMALE)),
male_adults_count=Count("id", distinct=True, filter=Q(birth_date__lte=date18ago, sex=MALE)),
female_adults_count=Count("id", distinct=True, filter=Q(birth_date__lte=date18ago, sex=FEMALE)),
total_individuals_count=Count("id", distinct=True),
)

self.female_children_count = targeted_individuals.get("female_children_count", 0)
self.male_children_count = targeted_individuals.get("male_children_count", 0)
self.female_adults_count = targeted_individuals.get("female_adults_count", 0)
self.male_adults_count = targeted_individuals.get("male_adults_count", 0)
self.total_households_count = households_ids.count()
self.total_individuals_count = (
self.female_children_count + self.male_children_count + self.female_adults_count + self.male_adults_count
)
self.total_individuals_count = targeted_individuals.get("total_individuals_count", 0)

self.save(
update_fields=[
Expand Down
3 changes: 3 additions & 0 deletions src/hct_mis_api/apps/targeting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ class TargetingCollectorRuleFilterBlock(
related_name="collectors_filters_blocks",
)

def get_collector_block_filters(self) -> "QuerySet":
return self.collector_block_filters.all()


class TargetingCollectorBlockRuleFilter(TimeStampedUUIDModel, TargetingCriteriaFilterBase):
"""
Expand Down
3 changes: 3 additions & 0 deletions src/hct_mis_api/migrations_script/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ def apply_migrations():
excluded_migrations = [
("targeting", "0002_migration"),
("household", "0003_migration"),
("household", "0004_migration"),
("grievance", "0004_migration"),
("payment", "0002_migration"),
("payment", "0003_migration"),
("payment", "0004_migration"),
("payment", "0005_migration"),
("aurora", "0003_migration"),
]
fake_migrations(excluded_migrations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from hct_mis_api.apps.core.models import BusinessArea
from hct_mis_api.apps.core.utils import timezone_datetime
from hct_mis_api.apps.geo.models import Area
from hct_mis_api.apps.household.models import FEMALE, MALE
from hct_mis_api.apps.household.models import SEX_CHOICE
from hct_mis_api.apps.program.models import Program


Expand Down Expand Up @@ -62,7 +62,7 @@ def validate_sex(
) -> Optional[str]:
if value is None or value == "":
return None
sex_choices = [MALE, FEMALE]
sex_choices = [value for value, _ in SEX_CHOICE]
if value not in sex_choices:
return f"Invalid value {value} for column {name}"
return None
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/api/test_push_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
HEAD,
IDENTIFICATION_TYPE_BIRTH_CERTIFICATE,
MALE,
NOT_COLLECTED,
DocumentType,
PendingDocument,
PendingHousehold,
Expand Down Expand Up @@ -73,7 +74,7 @@ def test_upload_single_person(self) -> None:
"collect_individual_data": COLLECT_TYPE_FULL,
"full_name": "John Doe",
"birth_date": "2000-01-01",
"sex": "MALE",
"sex": "NOT_COLLECTED",
"type": "",
}
]
Expand All @@ -95,7 +96,7 @@ def test_upload_single_person(self) -> None:
self.assertEqual(hh.village, "village1")

self.assertEqual(ind.full_name, "John Doe")
self.assertEqual(ind.sex, MALE)
self.assertEqual(ind.sex, NOT_COLLECTED)
self.assertEqual(ind.relationship, HEAD)

self.assertEqual(response_json["id"], str(self.rdi.id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8528,6 +8528,36 @@
}
],
'value': 'MALE'
},
{
'labelEn': 'Not answered',
'labels': [
{
'label': 'Not answered',
'language': 'English(EN)'
}
],
'value': 'NOT_ANSWERED'
},
{
'labelEn': 'Not collected',
'labels': [
{
'label': 'Not collected',
'language': 'English(EN)'
}
],
'value': 'NOT_COLLECTED'
},
{
'labelEn': 'Other',
'labels': [
{
'label': 'Other',
'language': 'English(EN)'
}
],
'value': 'OTHER'
}
],
'hint': '',
Expand Down
Binary file modified tests/unit/apps/core/test_files/kobo-template-invalid.xlsx
Binary file not shown.
Binary file modified tests/unit/apps/core/test_files/kobo-template-valid.xlsx
Binary file not shown.
4 changes: 3 additions & 1 deletion tests/unit/apps/grievance/test_close_data_change_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
HEAD,
IDENTIFICATION_TYPE_BIRTH_CERTIFICATE,
IDENTIFICATION_TYPE_NATIONAL_ID,
NOT_ANSWERED,
ROLE_PRIMARY,
SINGLE,
BankAccountInfo,
Expand Down Expand Up @@ -264,7 +265,7 @@ def setUpTestData(cls) -> None:
"full_name": {"value": "Test Example", "approve_status": True},
"family_name": {"value": "Example", "approve_status": True},
"phone_no_alternative": {"value": "+48602203689", "approve_status": True},
"sex": {"value": "MALE", "approve_status": False},
"sex": {"value": "NOT_ANSWERED", "approve_status": True},
"birth_date": {"value": date(year=1980, month=2, day=1).isoformat(), "approve_status": False},
"marital_status": {"value": SINGLE, "approve_status": True},
"role": {"value": ROLE_PRIMARY, "approve_status": True},
Expand Down Expand Up @@ -405,6 +406,7 @@ def test_close_update_individual(self, _: Any, permissions: List[Permissions], s
self.assertEqual(individual.phone_no_alternative, "+48602203689")
self.assertEqual(individual.phone_no_alternative_valid, True)
self.assertEqual(individual.marital_status, SINGLE)
self.assertEqual(individual.sex, NOT_ANSWERED)
self.assertNotEqual(individual.birth_date, date(year=1980, month=2, day=1))

role = individual.households_and_roles.get(role=ROLE_PRIMARY, individual=individual)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/apps/grievance/test_reassign_roles_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
)
from hct_mis_api.apps.household.fixtures import HouseholdFactory, IndividualFactory
from hct_mis_api.apps.household.models import (
RELATIONSHIP_UNKNOWN,
ROLE_ALTERNATE,
ROLE_PRIMARY,
UNKNOWN,
Individual,
IndividualRoleInHousehold,
)
Expand Down Expand Up @@ -97,7 +97,7 @@ def test_reassign_roles_on_marking_as_duplicate_individual_service(self) -> None
self.household.refresh_from_db()
self.assertEqual(self.household.head_of_household, self.no_role_individual)
for individual in self.household.individuals.exclude(id=self.no_role_individual.id):
self.assertEqual(individual.relationship, UNKNOWN)
self.assertEqual(individual.relationship, RELATIONSHIP_UNKNOWN)

def test_reassign_roles_on_marking_as_duplicate_individual_service_wrong_program(self) -> None:
program_two = ProgramFactory(name="Test program TWO", business_area=self.business_area)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/apps/household/test_individual_xlsx_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
FEMALE,
HEAD,
MALE,
OTHER,
SON_DAUGHTER,
WIFE_HUSBAND,
XlsxUpdateFile,
Expand Down Expand Up @@ -119,7 +120,7 @@ def setUpTestData(cls) -> None:
"phone_no": "934-25-25-121",
"phone_no_alternative": "",
"relationship": SON_DAUGHTER,
"sex": FEMALE,
"sex": OTHER,
"birth_date": "1985-08-12",
},
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/apps/registration_datahub/test_rdi_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def test_merging_external_collector(self) -> None:
"family_name": "Collector",
"relationship": NON_BENEFICIARY,
"birth_date": "1962-02-02", # age 39
"sex": "MALE",
"sex": "OTHER",
"registration_data_import": self.rdi,
"email": "xd@com",
}
Expand Down

0 comments on commit c7317f8

Please sign in to comment.