-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: frontend buttons to load Entities in ODK Collect by intent (#1449)
* feat: add endpoint for easy entities upload from csv file * feat: add logic to get project entities, get and update entity mapping status * feat: add project/entities and project/entity-mapping-status endpoints * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * feat: endpoints for getting and updating entity status * feat: add endpoint for minimal entity_uuid:osm_id mapping * fix(backend): handle cases when select_one_from_file is either geojson or csv * feat(frontend): add popup for task feature (entity) selection with link to odk by intent * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix(backend): handle edge case when task area contains no geometries (fmtm-splitter #28) * build: update osm-fiedwork --> v0.8.2 * refactor: wrap usage of OdkEntity in helper func with error handling * refactor: directly pass project_info to model during proj create * refactor: simplify project creation, divide into separate odk function * refactor: rename state osm:entity mapping var for clarity * refactor: change label on odk intent button --> map feature in odk * fix(backend): functions to update existing xform after entity update * refactor(frontend): allow default odk creds label to be clicked to toggle * fix(backend): do not pretty print final odk xml (minify) * build: upgrade osm-fieldwork --> 0.9.0 for entities workflow * refactor: update references to osm_fieldwork entity registration form * fix: update xform manipulation to factor in entities fields --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9bd5839
commit ac05dea
Showing
19 changed files
with
498 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright (c) 2022, 2023 Humanitarian OpenStreetMap Team | ||
# | ||
# This file is part of FMTM. | ||
# | ||
# FMTM is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# FMTM is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>. | ||
# | ||
|
||
"""ODK Central dependency wrappers.""" | ||
|
||
from contextlib import asynccontextmanager | ||
|
||
from fastapi.exceptions import HTTPException | ||
from osm_fieldwork.OdkCentralAsync import OdkEntity | ||
|
||
from app.models.enums import HTTPStatus | ||
from app.projects.project_schemas import ODKCentralDecrypted | ||
|
||
|
||
@asynccontextmanager | ||
async def get_odk_entity(odk_creds: ODKCentralDecrypted): | ||
"""Wrap getting an OdkEntity object with ConnectionError handling.""" | ||
try: | ||
async with OdkEntity( | ||
url=odk_creds.odk_central_url, | ||
user=odk_creds.odk_central_user, | ||
passwd=odk_creds.odk_central_password, | ||
) as odk_central: | ||
yield odk_central | ||
except ConnectionError as conn_error: | ||
raise HTTPException( | ||
status_code=HTTPStatus.BAD_REQUEST, detail=str(conn_error) | ||
) from conn_error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.