adhocracy
adhocracy copied to clipboard
Amendments sometimes don't have a selection
Sometimes amendments don't have a selection. When trying to access their selections, an exception is thrown. This leads to a 500 error on the instance overview.
A workaround is to either delete the proposal or add a selection. But when I added a selection, the amendment was still not visible in the amendment overlay.
Here is the script to add missing selections. Note that for some reason this is counted as a selection, but it does not show up in the sidebar.
from adhocracy.lib.text import variant_normalize
from adhocracy import model
def fix_selection(proposal_id, page_id):
proposal = model.Proposal.find(proposal_id)
page = model.Page.find(page_id)
variant = variant_normalize(proposal.title)
selection = model.Selection.create(proposal, page, proposal.creator, variant=variant)
model.meta.Session.commit()
Note: page_id
is the page the amendment refers to / changes. This may need to be deducted from the content.