Skip to content

Commit

Permalink
refactor(backend): remove task_id and task_filter params from XLSForm (
Browse files Browse the repository at this point in the history
…#1805)

* refactor: backend

do not require adding task_count to xlsform modification

* refactor(frontend): no longer add task_filter param to odk form intent

* refactor: frontend

remove task_filter logic as no longer in xlsform

* refactor(frontend): renamed new_feature_point --> new_feature in xlsform

* build: update osm-fieldwork --> 0.16.5 for latest xlsforms
  • Loading branch information
spwoodcock authored Sep 23, 2024
1 parent f2ae207 commit d368f03
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 24 deletions.
6 changes: 0 additions & 6 deletions src/backend/app/central/central_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ async def append_fields_to_user_xlsform(
xlsform: BytesIO,
form_category: str = "buildings",
additional_entities: list[str] = None,
task_count: int = None,
existing_id: str = None,
) -> tuple[str, BytesIO]:
"""Helper to return the intermediate XLSForm prior to convert."""
Expand All @@ -330,7 +329,6 @@ async def append_fields_to_user_xlsform(
xlsform,
form_category=form_category,
additional_entities=additional_entities,
task_count=task_count,
existing_id=existing_id,
)

Expand All @@ -339,15 +337,13 @@ async def validate_and_update_user_xlsform(
xlsform: BytesIO,
form_category: str = "buildings",
additional_entities: list[str] = None,
task_count: int = None,
existing_id: str = None,
) -> BytesIO:
"""Wrapper to append mandatory fields and validate user uploaded XLSForm."""
xform_id, updated_file_bytes = await append_fields_to_user_xlsform(
xlsform,
form_category=form_category,
additional_entities=additional_entities,
task_count=task_count,
existing_id=existing_id,
)

Expand All @@ -361,7 +357,6 @@ async def update_project_xform(
odk_id: int,
xlsform: BytesIO,
category: str,
task_count: int,
odk_credentials: project_schemas.ODKCentralDecrypted,
) -> None:
"""Update and publish the XForm for a project.
Expand All @@ -371,7 +366,6 @@ async def update_project_xform(
odk_id (int): ODK Central form ID.
xlsform (UploadFile): XForm data.
category (str): Category of the XForm.
task_count (int): The number of tasks in a project.
odk_credentials (project_schemas.ODKCentralDecrypted): ODK Central creds.
Returns: None
Expand Down
5 changes: 0 additions & 5 deletions src/backend/app/projects/project_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ async def validate_form(
if debug:
xform_id, updated_form = await central_crud.append_fields_to_user_xlsform(
xlsform,
task_count=1, # NOTE this must be included to append task_filter choices
)
return StreamingResponse(
updated_form,
Expand All @@ -687,7 +686,6 @@ async def validate_form(
else:
await central_crud.validate_and_update_user_xlsform(
xlsform,
task_count=1, # NOTE this must be included to append task_filter choices
)
return JSONResponse(
status_code=HTTPStatus.OK,
Expand Down Expand Up @@ -735,7 +733,6 @@ async def generate_files(
project = project_user_dict.get("project")
project_id = project.id
form_category = project.xform_category
task_count = len(project.tasks)

log.debug(f"Generating additional files for project: {project.id}")

Expand All @@ -746,7 +743,6 @@ async def generate_files(
await central_crud.validate_and_update_user_xlsform(
xlsform=xlsform_upload,
form_category=form_category,
task_count=task_count,
additional_entities=additional_entities,
)
xlsform = xlsform_upload
Expand All @@ -762,7 +758,6 @@ async def generate_files(
xform_id, project_xlsform = await central_crud.append_fields_to_user_xlsform(
xlsform=xlsform,
form_category=form_category,
task_count=task_count,
additional_entities=additional_entities,
)
# Write XLS form content to db
Expand Down
8 changes: 4 additions & 4 deletions src/backend/pdm.lock

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

2 changes: 1 addition & 1 deletion src/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies = [
"cryptography>=42.0.8",
"pyjwt>=2.8.0",
"async-lru>=2.0.4",
"osm-fieldwork>=0.16.5rc0",
"osm-fieldwork>=0.16.5",
"osm-login-python==2.0.0",
"osm-rawdata==0.3.2",
"fmtm-splitter==1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/DialogTaskActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export default function Dialog({ taskId, feature }: dialogPropType) {
);

if (isMobile) {
document.location.href = `odkcollect://form/${projectInfo.xform_id}?task_filter=${taskId}`;
document.location.href = `odkcollect://form/${projectInfo.xform_id}`;
} else {
dispatch(
CommonActions.SetSnackBar({
Expand Down
10 changes: 3 additions & 7 deletions src/frontend/src/views/SubmissionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ const SubmissionDetails = () => {
const projectDashboardLoading = useAppSelector((state) => state.project.projectDashboardLoading);
const submissionDetails = useAppSelector((state) => state.submission.submissionDetails);
const submissionDetailsLoading = useAppSelector((state) => state.submission.submissionDetailsLoading);
const taskId = submissionDetails?.task_id
? submissionDetails?.task_id
: submissionDetails?.task_filter
? submissionDetails?.task_filter
: '-';
const taskId = submissionDetails?.task_id ? submissionDetails?.task_id : '-';

const { start, end, today, deviceid, ...restSubmissionDetails } = submissionDetails || {};
const dateDeviceDetails = { start, end, today, deviceid };
Expand Down Expand Up @@ -158,7 +154,7 @@ const SubmissionDetails = () => {
const newFeaturePoint = {
type: 'Feature',
geometry: {
...restSubmissionDetails?.new_feature_point,
...restSubmissionDetails?.new_feature,
},
properties: {},
};
Expand Down Expand Up @@ -250,7 +246,7 @@ const SubmissionDetails = () => {
featureGeojson={
submissionDetailsLoading
? {}
: restSubmissionDetails?.new_feature === 'yes'
: restSubmissionDetails?.new_feature
? newFeaturePoint
: coordinatesArray
? geojsonFeature
Expand Down

0 comments on commit d368f03

Please sign in to comment.