Remove "destructive approval" from our approval step for existing providers #530
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.
This PR changes the behaviour to remove the default of deleting some data about a provider when we try to merge a new verification request into an existing provider.
Previously we had some logic like this:
We want to preserve existing IPs and documents where possible, so this PR moves to archive these safely instead.
What we do instead
With the new logic, we now have a set of
archive
andunarchive
methods on the objects we want to preserve, and where necessary, we use a new model manager to avoid surfacing archived content. This reduces the risk of data loss.With IP Ranges and ASN
As mentioned before, in the approval process, we call
archive()
on any matching IPs or ASNs. This uses theactive
state, so they no longer are used in greenchecks. If a verification request still has a matching IP range or ASN, weunarchive
them, so they are visible once again and show in greenchecks.With uploaded supporting evidence
Supporting evidence is a little more complicated. I've introduced an
archived
property on theAbstractSupportingDocument
model that all our evidence types inherit from.During the approval process, we call
archive()
on all supporting evidence on a provider, and then if there is matching information in the verification request, we callunarchive()
again, making it visible to the hosting provider. We honour the original public status, so information that was uploaded as not public, stays as not public.We do this by using a different model Manager on the HostingProviderSupportingDocument model, which means all queries by default exclude archived information. See
NonArchivedEvidenceManager
for more.If we need to access the archived evidence we still have an model Manager which does offer unfiltered queries - we can use this to search for archived content if need be.