This was a bug - the revert_person_from_version_data method,
which was used to implement merges of two candidates as well
as reverting them to an earlier version, deletes all existing
candidacies of a person and then recreates the ones that
should be there. However, the code was only actually removing
the MembershipExtra objects and leaving the Membership objects
in the database. These weren't shown on the user-facing site
because of missing the MembershipExtra objects, but would be
shown in the API output which was causing confusion.
This commit fixes that problem; a delete on the Membership
queryset deletes the corresponding MembershipExtras too.
Thanks to Sym Roe (@symroe) for spotting this and figuring
out that it related to merging.
This was a bug - the revert_person_from_version_data method, which was used to implement merges of two candidates as well as reverting them to an earlier version, deletes all existing candidacies of a person and then recreates the ones that should be there. However, the code was only actually removing the MembershipExtra objects and leaving the Membership objects in the database. These weren't shown on the user-facing site because of missing the MembershipExtra objects, but would be shown in the API output which was causing confusion.
This commit fixes that problem; a delete on the Membership queryset deletes the corresponding MembershipExtras too.
Thanks to Sym Roe (@symroe) for spotting this and figuring out that it related to merging.
Fixes #866