Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom data exports feature #2975

Merged
merged 84 commits into from
Mar 10, 2021
Merged

Custom data exports feature #2975

merged 84 commits into from
Mar 10, 2021

Conversation

joshuaberetta
Copy link
Member

@joshuaberetta joshuaberetta commented Jan 26, 2021

List of export settings for a specific asset

Required permissions: view_submissions (View submissions)

GET /api/v2/assets/{asset_uid}/export-settings/

Example

curl -X GET https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/export-settings/

CRUD

  • asset_uid - is the unique identifier of a specific asset
  • setting_uid - is the unique identifier of a specific export setting

Create an export setting for an asset

Required permissions: manage_asset (Manage project)

POST /api/v2/assets/{asset_uid}/export-settings/

Example

curl -X POST https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/export-settings/

Payload

{
    "name": "foo",
    "export_settings": {
        "fields_from_all_versions": "true",
        "group_sep": "/",
        "hierarchy_in_labels": "true",
        "lang": "English (en)",
        "multiple_select": "both",
        "type": "csv",
        "fields": ["field_1", "field_2"]
    }
}

where:

  • "name" (required) is the name of the export setting displayed in the UI
  • "export_settings" (required) is a map of defined settings containing the following valid options:
    • "fields" (optional) is an array of column names to be included in the export (including their group hierarchy). Valid inputs include:
      • An array containing any string value that matches the XML column name
      • An empty array which will result in all columns being included
      • If "fields" is not included in the "export_settings", all columns will be included in the export
    • "fields_from_all_versions" (required) is a boolean to specify whether fields from all form versions will be included in the export.
    • "group_sep" (required) is a value used to separate the names in a hierarchy of groups. Valid inputs include:
      • Non-empty value
    • "hierarchy_in_labels" (required) is a boolean to specify whether the group hierarchy will be displayed in labels
    • "multiple_select" (required) is a value to specify the display of multiple_select-type responses. Valid inputs include:
      • "both",
      • "summary", or
      • "details"
    • "type" (required) specifies the export format. Valid export formats include:
      • "csv",
      • "geojson",
      • "spss_labels",
      • "xls"

Retrieves a specific export setting

Required permissions: view_submissions (View submissions)

GET /api/v2/assets/{asset_uid}/export-settings/{setting_uid}/

Example

curl -X GET https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/export-settings/espj4oFeS9tVhQQMVfitTB2/

Updates an asset's export setting

Required permissions: manage_asset (Manage project)

PATCH /api/v2/assets/{asset_uid}/export-settings/{setting_uid}/

Example

curl -X PATCH https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/export-settings/espj4oFeS9tVhQQMVfitTB2/

Payload

{
    "name": "bar",
    "export_settings": {
        "fields_from_all_versions": "true",
        "group_sep": "/",
        "hierarchy_in_labels": "true",
        "lang": "English (en)",
        "multiple_select": "both",
        "type": "csv",
        "fields": ["field_1", "field_2", "field_3"]
    }
}

Deletes current export setting

Required permissions: manage_asset (Manage project)

DELETE /api/v2/assets/{asset_uid}/export-settings/{setting_uid}/

Example

curl -X DELETE https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/export-settings/espj4oFeS9tVhQQMVfitTB2/

Description

Allow for export setting preferences to be created and managed for an asset as well in including a new option for filtering exports by field.

Related issues

closes #2967
related to #2963, #2881

@joshuaberetta joshuaberetta added API Changes related to API endpoints Back end enhancement Ideas, improvements and features labels Jan 26, 2021
@joshuaberetta joshuaberetta linked an issue Jan 26, 2021 that may be closed by this pull request
@joshuaberetta joshuaberetta changed the title Custom data exports feature [WIP] Custom data exports feature Jan 27, 2021
Base automatically changed from 2332-collection-as-asset-type to beta January 30, 2021 07:05
@joshuaberetta joshuaberetta changed the title [WIP] Custom data exports feature Custom data exports feature Feb 5, 2021
@joshuaberetta joshuaberetta linked an issue Feb 5, 2021 that may be closed by this pull request
dependencies/pip/requirements.in Outdated Show resolved Hide resolved
kpi/models/asset_export_settings.py Outdated Show resolved Hide resolved
kpi/serializers/v2/asset_export_settings.py Show resolved Hide resolved
kpi/serializers/v2/asset_export_settings.py Show resolved Hide resolved
kpi/tests/test_asset_export_settings.py Outdated Show resolved Hide resolved
kpi/tests/test_asset_export_settings.py Outdated Show resolved Hide resolved
kpi/views/v2/asset_export_settings.py Show resolved Hide resolved
@joshuaberetta joshuaberetta requested a review from jnm March 4, 2021 23:04
@jnm jnm merged commit ba73150 into beta Mar 10, 2021
@jnm jnm deleted the 2967-custom-data-exports branch March 10, 2021 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes related to API endpoints Back end enhancement Ideas, improvements and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom data exports API implementation Custom Data Exports
3 participants