Check if image exists before deleting civs for archive items #3116
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.
When uploading a new image to an existing archive item, all non-image CIVs of that same item used to get deleted. The reason for this was that we checked for existing CIVs with the same image and deleted those. In the case of new image uploads, however, civ.image is still empty at the time of checking, and so it matched all CIVs with image=None.
I was confused why we need this check at all. After some digging, I realized that it's necessary to enable updating of the interface of an image through the api (say from generic medical image to something more specific). This was a common use case when it was added. I'm in doubt whether we still need or want to offer this feature. It means that you can never have an archive item with the same image attached to different interfaces. Seems like a reasonable restriction to me, but it's a restriction that we don't enforce anywhere else (i.e. for display sets or jobs) as far as I know.
Finally, adding a new interface to an archive item through the dropdown menu no longer worked since it used inline js. Fixed that as well.
Closes #3104