Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/hope/api/endpoints/rdi/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
HEAD,
IDENTIFICATION_TYPE_CHOICE,
ROLE_ALTERNATE,
ROLE_NO_ROLE,
ROLE_PRIMARY,
PendingDocument,
PendingHousehold,
Expand Down Expand Up @@ -143,10 +142,10 @@ class Meta:
]

def validate_role(self, value: str) -> str | None:
if value in (ROLE_NO_ROLE, ROLE_PRIMARY, ROLE_ALTERNATE):
if value in (ROLE_PRIMARY, ROLE_ALTERNATE):
return value
if not value:
return ROLE_NO_ROLE
return None
if value.upper()[0] == "P":
return ROLE_PRIMARY
if value.upper()[0] == "A":
Expand Down
8 changes: 7 additions & 1 deletion src/hope/apps/core/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ class KoboTemplateValidator:
"deviceid": TYPE_STRING,
}
EXPECTED_REQUIRED_FIELDS = (
"country_h_csize_h_crelationship_i_crole_i_cfull_name_i_cgender_i_cbirth_date_i_cestimated_birth_date_i_c"
"country_h_c",
"size_h_c",
"relationship_i_c",
"full_name_i_c",
"gender_i_c",
"birth_date_i_c",
"estimated_birth_date_i_c",
)
FIELDS_EXCLUDED_FROM_CHOICE_CHECK = (
# temporarily disabled from checking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
HEAD,
NON_BENEFICIARY,
RELATIONSHIP_UNKNOWN,
ROLE_NO_ROLE,
Document,
Household,
Individual,
Expand Down Expand Up @@ -95,7 +94,7 @@ def close(self, user: AbstractUser) -> None:
individual_data = details.individual_data
documents = individual_data.pop("documents", [])
identities = individual_data.pop("identities", [])
role = individual_data.pop("role", ROLE_NO_ROLE)
role = individual_data.pop("role", None)
individual_data["flex_fields"] = populate_pdu_with_null_values(
household.program, individual_data.get("flex_fields", None)
)
Expand Down
19 changes: 19 additions & 0 deletions src/hope/apps/household/migrations/0025_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.25 on 2025-08-20 14:36

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("household", "0024_migration"),
]

operations = [
migrations.AlterField(
model_name="individualroleinhousehold",
name="role",
field=models.CharField(
choices=[("ALTERNATE", "Alternate collector"), ("PRIMARY", "Primary collector")], max_length=255
),
),
]
2 changes: 0 additions & 2 deletions src/hope/apps/household/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
ROLE_ALTERNATE = "ALTERNATE"
ROLE_NO_ROLE = "NO_ROLE"
ROLE_CHOICE = (
(ROLE_NO_ROLE, "None"),
(ROLE_ALTERNATE, "Alternate collector"),
(ROLE_PRIMARY, "Primary collector"),
)
Expand Down Expand Up @@ -1072,7 +1071,6 @@ class IndividualRoleInHousehold(SoftDeletableMergeStatusModel, TimeStampedUUIDMo
)
role = models.CharField(
max_length=255,
blank=True,
choices=ROLE_CHOICE,
)
copied_from = models.ForeignKey(
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.
Binary file not shown.
Loading