liqd / adhocracy

Adhocracy is a policy drafting and decision making software for distributed groups and open institutions.
GNU Affero General Public License v3.0
150 stars 37 forks source link

Amendments sometimes don't have a selection #950

Open xi opened 9 years ago

xi commented 9 years ago

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.

xi commented 8 years ago

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()
nidico commented 8 years ago

Note: page_id is the page the amendment refers to / changes. This may need to be deducted from the content.