Skip to content

Commit

Permalink
Merge pull request #27 from onaio/additional-export-options
Browse files Browse the repository at this point in the history
Add additional `binary_select_multiples` & `show_choice_labels` export configurations
  • Loading branch information
DavisRayM authored Jan 20, 2022
2 parents 3dc0f2c + 24576bc commit 9082518
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ This project has been funded by DG ECHO and implemented by Caritas Switzerland a

All release notes for this project will be documented in this file; this project follows [Semantic Versioning](https://semver.org/).

## v0.0.7 - 2022-01-20

### Bug fixes and improvements :bug:

- Add additional export configurations. PR [#27](https://github.com/onaio/duva/pull/27)

## v0.0.6 - 2021-10-25

### Bug fixes and improvements :bug:
Expand Down
2 changes: 2 additions & 0 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class ExportConfigurationSettings(BaseModel):
include_reviews: Optional[bool] = False
include_labels_only: Optional[bool] = True
value_select_multiples: Optional[bool] = True
show_choice_labels: Optional[bool] = True
binary_select_multiples: Optional[bool] = True


class ConfigurationResponse(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Settings(BaseSettings):
app_name: str = "Duva"
app_description: str = ""
app_version: str = "v0.0.6"
app_version: str = "v0.0.7"
app_host: str = "127.0.0.1"
app_port: int = 8000
database_url: str = "postgres://duva:[email protected]/duva"
Expand Down
9 changes: 4 additions & 5 deletions app/tests/utils/test_onadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ def test_get_csv_export(
)
assert ret == Path(file_mock.name)
mock_get_access_token.assert_called_with(user, server, self.db)
expected_query_params = "&".join(
[
f"{param}={value}"
for param, value in configuration.export_settings.items()
]
expected_query_params = (
"include_labels=True&remove_group_name=True&do_not_split_select_multiple=False"
"&include_reviews=False&include_labels_only=True&value_select_multiples=True&"
"show_choice_labels=True&binary_select_multiples=True"
)
mock_get_csv_export.assert_called_with(
f"{server.url}/api/v1/forms/{hyperfile.form_id}/export_async.json?format=csv&{expected_query_params}",
Expand Down
5 changes: 4 additions & 1 deletion app/utils/onadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def get_csv_export(
if resp.status_code == 200:
url = f"{form_url}/export_async.json?format=csv"
if hyperfile.configuration:
export_settings = hyperfile.configuration.export_settings
export_settings = schemas.ExportConfigurationSettings(
**hyperfile.configuration.export_settings
).dict()

for key, value in export_settings.items():
url += f"&{key}={value}"

Expand Down

0 comments on commit 9082518

Please sign in to comment.