Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a child election does not update the parent's modified timestamp #2289

Open
awdem opened this issue Oct 30, 2024 · 1 comment
Open
Labels

Comments

@awdem
Copy link
Contributor

awdem commented Oct 30, 2024

Peter deleted a ballot-level election that was made mistakenly. This updated the modified timestamp for the ballot-level election, but didn't update its parent election's modified timestamp.

Aside from this causing some issues with other project's EE importers, it would make sense that deleting a child election also updates the parent election's modified timestamp because the parent has one less child.

For more info on the soft delete system: https://github.com/DemocracyClub/EveryElection/wiki/Cancelled-Elections-and-Soft-Deletes

One potential fix:

In the ModerationHistory.save() method, touch the modified date of any parent elections as well as the election object itself:

def save(self, **kwargs):
# if this is the initial status no need to update the related election
# so return early. This is because the default status is identical on
# both this model and the Election model
if kwargs.pop("initial_status", False):
return super().save(**kwargs)
# save the related election to update the modified timestamp so that it
# is found by the importer looking for recent changes
if self.election.current_status != self.status.short_label:
self.election.current_status = self.status.short_label
self.election.save()
super().save(**kwargs)
return None

related issue on YNR: #2289

@awdem
Copy link
Contributor Author

awdem commented Nov 5, 2024

Adjacent issue:

two ballot-level elections were created and approved after their parent election local.2024-12-05. Their creation and approval didn't update the parent election modified timestamp. These ballot-level elections weren't synced by YNR because it only syncs recently modified parent elections. I think that this a change like the one suggested above would also address this issue, but it worth investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant