Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Frontend PR: ohcnetwork/care_fe#6262
Summary
This PR introduces several changes to the
Asset
model and its related serializers and viewsets in thecare/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
AssetType
andStatus
enums are now defined outside theAsset
model, and their choices are generated separately asAssetTypeChoices
andStatusChoices
.CSV_MAPPING
dictionary is added to map model fields to human-readable CSV headers.CSV_MAKE_PRETTY
dictionary is added to provide functions for converting database values to human-readable strings for CSV exports.Asset Serializer
status
andasset_type
fields now use theStatusChoices
andAssetTypeChoices
generated outside theAsset
model.Asset ViewSet
list
method is overridden to support CSV export of asset data. If theCSV_REQUEST_PARAMETER
is present in the request, the method generates a CSV file with headers and values based on theCSV_MAPPING
andCSV_MAKE_PRETTY
dictionaries in theAsset
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.