Ejemplo n.º 1
0
    def sequencing_hook(self, db_session, parent_block_data, parent_sequenced_block_data):

        for proposal_audit in DemocracyProposalAudit.query(db_session).filter_by(block_id=self.block.id).order_by('event_idx'):

            if proposal_audit.type_id == DEMOCRACY_PROPOSAL_AUDIT_TYPE_PROPOSED:
                status = 'Proposed'
            elif proposal_audit.type_id == DEMOCRACY_PROPOSAL_AUDIT_TYPE_TABLED:
                status = 'Tabled'
            else:
                status = '[unknown]'

            try:
                proposal = DemocracyProposal.query(db_session).filter_by(id=proposal_audit.democracy_proposal_id).one()

                proposal.status = status
                proposal.updated_at_block = self.block.id

            except NoResultFound:

                proposal = DemocracyProposal(
                    id=proposal_audit.democracy_proposal_id,
                    proposal=proposal_audit.data['proposal'],
                    bond=proposal_audit.data['bond'],
                    created_at_block=self.block.id,
                    updated_at_block=self.block.id,
                    status=status
                )

            proposal.save(db_session)
Ejemplo n.º 2
0
 def accumulation_revert(self, db_session):
     for item in DemocracyProposalAudit.query(db_session).filter_by(block_id=self.block.id):
         db_session.delete(item)