def get_count_query(self):
        '''Override default get count query to conform to above
        '''
        last_stage = db.session.query(
            Flow.id,
            Flow.stage_order[db.func.array_upper(Flow.stage_order, 1)].label('last')
        ).subquery()

        return super(ConductorContractAdmin, self).get_count_query().outerjoin(
            last_stage
        ).outerjoin(
            ContractStage, db.and_(
                ContractBase.current_stage_id == ContractStage.stage_id,
                ContractBase.id == ContractStage.contract_id,
                ContractBase.flow_id == ContractStage.flow_id
            )
        ).filter(
            db.or_(
                db.and_(
                    ContractBase.current_stage_id == last_stage.c.last,
                    ContractStage.exited != None
                ),
                ContractBase.current_stage_id != last_stage.c.last,
                ContractBase.current_stage_id != None
            )
        )
    def get_count_query(self):
        '''Override default get query to limit to assigned contracts
        '''
        last_stage = db.session.query(
            Flow.id,
            Flow.stage_order[db.func.array_upper(Flow.stage_order, 1)].label('last')
        ).subquery()

        return super(ScoutContractAdmin, self).get_count_query().outerjoin(
            last_stage,
        ).outerjoin(
            ContractStage, db.and_(
                ContractBase.current_stage_id == ContractStage.stage_id,
                ContractBase.id == ContractStage.contract_id,
                ContractBase.flow_id == ContractStage.flow_id
            )
        ).filter(
            db.or_(
                ContractBase.current_stage_id == None,
                ContractBase.is_archived == True,
                db.and_(
                    ContractBase.current_stage_id == last_stage.c.last,
                    ContractStage.exited != None
                )
            )
        )
Ejemplo n.º 3
0
    def get_count_query(self):
        '''Override default get query to limit to assigned contracts
        '''
        last_stage = db.session.query(
            Flow.id,
            Flow.stage_order[db.func.array_upper(Flow.stage_order,
                                                 1)].label('last')).subquery()

        return super(ScoutContractAdmin, self).get_count_query().outerjoin(
            last_stage, ).outerjoin(
                ContractStage,
                db.and_(
                    ContractBase.current_stage_id == ContractStage.stage_id,
                    ContractBase.id == ContractStage.contract_id,
                    ContractBase.flow_id == ContractStage.flow_id)).filter(
                        db.or_(
                            ContractBase.current_stage_id == None,
                            ContractBase.is_archived == True,
                            db.and_(
                                ContractBase.current_stage_id ==
                                last_stage.c.last,
                                ContractStage.exited != None)))
Ejemplo n.º 4
0
    def get_count_query(self):
        '''Override default get count query to conform to above
        '''
        last_stage = db.session.query(
            Flow.id,
            Flow.stage_order[db.func.array_upper(Flow.stage_order,
                                                 1)].label('last')).subquery()

        return super(
            ConductorContractAdmin,
            self).get_count_query().outerjoin(last_stage).outerjoin(
                ContractStage,
                db.and_(
                    ContractBase.current_stage_id == ContractStage.stage_id,
                    ContractBase.id == ContractStage.contract_id,
                    ContractBase.flow_id == ContractStage.flow_id)).filter(
                        db.or_(
                            db.and_(
                                ContractBase.current_stage_id ==
                                last_stage.c.last,
                                ContractStage.exited != None),
                            ContractBase.current_stage_id != last_stage.c.last,
                            ContractBase.current_stage_id != None))