Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 28, 2024
2 parents 582c538 + 10b93cc commit fde33f5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
repos:
# Versioning: Commit messages & changelog
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.1
rev: v3.31.0
hooks:
- id: commitizen
stages: [commit-msg]

# Lint / autoformat: Python code
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: "v0.7.3"
rev: "v0.8.0"
hooks:
# Run the linter
- id: ruff
Expand All @@ -33,7 +33,7 @@ repos:

# Lint: Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
rev: v0.43.0
hooks:
- id: markdownlint
args:
Expand Down
14 changes: 13 additions & 1 deletion osm_fieldwork/update_xlsform.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,22 @@ def append_select_one_from_file_row(df: pd.DataFrame, entity_name: str) -> pd.Da
}
)

# Prepare the row for calculating coordinates based on the additional entity
coordinates_row = pd.DataFrame(
{
"type": ["calculate"],
"name": ["additional_geometry"],
"calculation": [f"instance('{entity_name}')/root/item[name=${entity_name}]/geometry"],
"label::English(en)": ["additional_geometry"],
"label::Swahili(sw)": ["additional_geometry"],
"label::French(fr)": ["additional_geometry"],
"label::Spanish(es)": ["additional_geometry"],
}
)
# Insert the new row into the DataFrame
top_df = df.iloc[:row_index_to_split_on]
bottom_df = df.iloc[row_index_to_split_on:]
return pd.concat([top_df, additional_row, bottom_df], ignore_index=True)
return pd.concat([top_df, additional_row, coordinates_row, bottom_df], ignore_index=True)


async def append_mandatory_fields(
Expand Down
Binary file modified osm_fieldwork/xlsforms/common/digitisation_fields.xls
Binary file not shown.
Binary file modified osm_fieldwork/xlsforms/common/mandatory_fields.xls
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/test_update_xlsform.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ async def test_add_extra_select_from_file():
survey_sheet = workbook["survey"]
name_column = [cell.value for cell in survey_sheet["B"]]

assert "road" in name_column, "The 'road' field was not added to the survey sheet."
assert "waterpoint" in name_column, "The 'waterpoint' field was not added to the survey sheet."
assert "roads" in name_column, "The 'roads' field was not added to the survey sheet."
assert "waterpoints" in name_column, "The 'waterpoints' field was not added to the survey sheet."


async def test_buildings_xlsform():
Expand All @@ -82,7 +82,7 @@ async def test_buildings_xlsform():

workbook = load_workbook(filename=BytesIO(updated_form.getvalue()))
translation_found, label_field_found = check_translation_fields(workbook)
assert translation_found, "'label::English(en)' field not found in the survey sheet."
assert translation_found, "'label::english(en)' field not found in the survey sheet."
assert not label_field_found, "'label' field should not be present after merging translations."


Expand Down Expand Up @@ -145,7 +145,7 @@ def check_translation_fields(workbook: Workbook):
for row in survey_sheet.iter_rows(min_row=1, max_col=survey_sheet.max_column):
for cell in row:
# Check if the English translation label exists
if cell.value == "label::English(en)":
if cell.value == "label::english(en)":
translation_found = True

# Ensure that the base 'label' field is no longer present
Expand Down

0 comments on commit fde33f5

Please sign in to comment.