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

CSV export for Assets #1592

Merged
merged 1 commit into from
Sep 11, 2023
Merged

CSV export for Assets #1592

merged 1 commit into from
Sep 11, 2023

Conversation

Ashesh3
Copy link
Member

@Ashesh3 Ashesh3 commented Sep 11, 2023

Frontend PR: ohcnetwork/care_fe#6262

Summary

This PR introduces several changes to the Asset model and its related serializers and viewsets in the care/facility app. The primary goal is to improve the handling of asset types and statuses, and to support CSV export of asset data.

Changes

Asset Model

  • The AssetType and Status enums are now defined outside the Asset model, and their choices are generated separately as AssetTypeChoices and StatusChoices.
  • Reversed mappings for asset types and statuses are created for use in CSV exports.
  • A CSV_MAPPING dictionary is added to map model fields to human-readable CSV headers.
  • A CSV_MAKE_PRETTY dictionary is added to provide functions for converting database values to human-readable strings for CSV exports.

Asset Serializer

  • The status and asset_type fields now use the StatusChoices and AssetTypeChoices generated outside the Asset model.

Asset ViewSet

  • The list method is overridden to support CSV export of asset data. If the CSV_REQUEST_PARAMETER is present in the request, the method generates a CSV file with headers and values based on the CSV_MAPPING and CSV_MAKE_PRETTY dictionaries in the Asset model.

Testing

Please ensure that these changes do not break existing functionality, particularly around the handling of asset types and statuses. Also, please test the new CSV export functionality and ensure that the exported data matches the specified mappings and transformations.

Closing

These changes should improve the flexibility and usability of the asset management features in the care/facility app. Please review and provide any feedback.

@Ashesh3
Copy link
Member Author

Ashesh3 commented Sep 11, 2023

Tests passing locally:

----------------------------------------------------------------------
Ran 116 tests in 7.164s

OK

@Ashesh3 Ashesh3 added the P1 High priority; urgent label Sep 11, 2023
@vigneshhari vigneshhari merged commit cbc0603 into master Sep 11, 2023
4 of 5 checks passed
@vigneshhari vigneshhari deleted the asset_csv_export branch September 11, 2023 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 High priority; urgent waiting-for-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants