OSH: Delete matched facilities from created contributer #2153
OSH: Delete matched facilities from created contributer #2153
Conversation
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.
Excellent work. I tested this manually as well and it works as expected.
src/django/api/tests.py
Outdated
response = self.client.delete(self.facility_url) | ||
self.assertEqual(204, response.status_code) | ||
|
||
# Both facilities should be deleted because they are |
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.
Checking the language on this comment.
It says "Both facilities should be deleted.." but based on context I think this should be something like "The facility should be deleted and not be replaced since both items/matches came from the same contributor."
If a facility has more than one match, those other matches could be promoted when the original facility is deleted. This means that a contributer might need to delete a facility many times to fully delete the facility. In order to simplify the delete process, facility list items from the same contributor as the original facility should be deleted along with the original facility. This includes the matches associated with these facility list items. This commit accomplishes this by adding facility list items from the same contributor as the created_from contributor of the facility to be deleted to the list of facility list items to delete. Additionally, when looking for a best match to promote, facilitiy list items from the original contributor are excluded. If no best match is found, nothing changes since all matches and list items are deleted anyway. If a best match is found, any matches from the original contributor are deleted along with their list items.
e827798
to
4cd2a18
Compare
@mstone121 Sorry for introducing some confusion when we chatted about CC @mariel-oar @vrwOAR to double check me on this. |
OS Hub confirmed that we want this behavior in both branches. We have done this for other PRs by opening a second PR and referencing the first PR in the description. |
Overview
If a facility has more than one match, those other matches could be promoted when the original facility is deleted. This means that a contributer might need to delete a facility many times to fully delete the facility.
In order to simplify the delete process, facility list items from the same contributor as the original facility should be deleted along with the original facility. This includes the matches associated with these facility list items.
Connects #2124
Notes
This PR has some code with strange looking destructuring with the python double astrisks operator:
I did this to make the linter happy. I couldn't figure out a way to separate keyword arguments on more than one line (and when it's on one line it's too long for the linter). I'm open to suggestions on better ways to format this.
Testing Instructions
./scripts/manage test api.tests.FacilityDeleteTest
Checklist
fixup!
commits have been squasheddevelop
vs.ogr/develop
)