Join GitHub today
MBS-10432 / MBS-10433 / MBS-10437: Block adding removal edits for areas that shouldn't be removed #1240
Places use areas too, but currently we allow entering a removal edit for an area that's only being used in places. This edit can't be applied, since the database has a foreign key, but it shouldn't be possible to enter in the first place.
Any area in the country_area table can't be removed anyway, since there are constraints at the database level blocking that. We shouldn't allow entering an edit trying to remove a country area. This makes the release country check in can_delete redundant, so replacing that with a call to is_release_country_area.
If an area has any relationships, it's safer not to allow removing it. This also blocks removing it if it has open edits. It makes sure a removal edit is not opened if the area is already being merged, and since location editors are pretty much always going to be autoeditors, they shouldn't have a problem approving most other edits if needed. Because all the previous checks for can_delete are subsets of this new query, we can just remove them and only leave this check plus the check for whether the area is a release country (where we still want to block removing it even if it is otherwise empty!). Since the release country check will apply to all areas used on releases, there is no need to check the release_country table in this query.
reosarevok merged commit
Oct 21, 2019
4 checks passed
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.