-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Delete Case Types and Properties in Data Dictionary #33956
Conversation
corehq/apps/data_dictionary/views.py
Outdated
@require_permission(HqPermissions.edit_data_dict) | ||
def delete_case_type(request, domain, case_type_name): | ||
case_type_obj = CaseType.objects.get(domain=domain, name=case_type_name) | ||
case_type_obj.delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do we want to check for missing case type here like we did in delete_case_property
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a good check to have. Although I don't foresee this scenario happening, there might be an unforeseen edge case and so we should rather stay on the cautious side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | ||
prop = CaseProperty.objects.get(name=name, case_type__name=case_type, case_type__domain=domain) | ||
except CaseProperty.DoesNotExist: | ||
return gettext('Case property does not exist.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I see we have done it elsewhere. Should translations be done in the util module or should they be limited to views?
I guess I would go for latter but don't have a strong reason against it keeping it in util, specially if its already being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be fine to keep in the util module. There are other functions in this module, such as save_case_property()
, which also use gettext
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the feedback @zandre-eng
All non blocking feedback.
Just confirming that comms for this change have already been setup/addressed?
Given the size of this PR, I am closing it off in favour of this one which contains a cleaned up commit history. |
Product Description
There is a new button to delete a case property. This button is contextual and will only appear for case properties that are not being used to store actual case data:
Clicking on the case property delete button will cause a confirmation modal to pop up:
After the user has clicked to confirm deletion, the case property will then be marked as deleted. The user will then need to confirm all changes by clicking "Save" at the top-right corner. This follows the same workflow as deprecating a case property.
Similarly, there is a new button to delete a case type. This button is also contextual and only appears if both the case type and all its case properties are not being used by cases:
Clicking the case type delete button will cause a confirmation modal to pop up:
Once the user has confirmed to delete a case type, the page will be refreshed and the deleted case type will be gone from the left-hand side.
If there is an error with deleting a case type, a generic error message will be shown to the user:
Technical Summary
Link to ticket here.
This adds in the ability for a user to delete case types/properties. It should be noted however, that this only applies to case types/properties that have no associated case data. Once a case starts using a specific case type/property, the type/property can then no longer be deleted in the Data Dictionary. The only way to achieve deleting it would be to first remove the relevant cases.
Feature Flag
None.
Safety Assurance
Safety story
Automated test coverage
Automated tests have been created for the new view and util functions for deleting a case type. Furthermore, the existing unit tests for updating a case property have been updated to test for deleting case properties as well.
QA Plan
QA has passed. Ticket available here.
Rollback instructions
Labels & Review