Пример #1
0
class MemberItemsViewlet(browser.BungeniItemsViewlet):
    """A tab with bills, motions etc for an MP 
    (the "parliamentary activities" tab of of the "member" view)
    """
    #!+weight = 40

    states = _get_public_states_for(*[
        ti for (key, ti) in capi.iter_type_info()
        if ti.custom and issubclass(ti.domain_model, domain.Doc)
    ])

    render = ViewPageTemplateFile("templates/mp-item-viewlet.pt")

    def __init__(self, context, request, view, manager):
        super(MemberItemsViewlet, self).__init__(context, request, view,
                                                 manager)
        user_id = self.context.user_id
        chamber_id = self.context.group_id
        self.query = Session().query(domain.Doc).filter(
            sql.and_(
                domain.Doc.owner_id == user_id,
                domain.Doc.chamber_id == chamber_id,
                domain.Doc.status.in_(self.states),
            ))
        #self.for_display = (self.query.count() > 0)
        self.formatter = self.get_date_formatter("date", "medium")

    def update(self):
        user_id = self.context.user_id
        chamber_id = self.context.group_id
        wf = capi.get_type_info("signatory").workflow
        session = Session()
        # add cosigned items
        signed_pi_ids = [
            sgn.head_id for sgn in session.query(domain.Signatory).filter(
                sql.and_(
                    domain.Signatory.user_id == user_id,
                    domain.Signatory.status.in_(
                        wf.get_state_ids(tagged=["public"])),
                )).all()
        ]
        if len(signed_pi_ids) > 0:
            self.query = self.query.union(
                session.query(domain.Doc).filter(
                    sql.and_(domain.Doc.chamber_id == chamber_id,
                             domain.Doc.status.in_(self.states),
                             domain.Doc.doc_id.in_(signed_pi_ids))))
        self.query = self.query.order_by(domain.Doc.doc_id.desc())

    @property
    def items(self):
        for item in self.query.all():
            _url = "/business/%ss/obj-%i" % (item.type, item.doc_id)
            yield {
                "type": item.type,
                "title": item.title,
                "status": misc.get_wf_state(item),
                "submission_date": item.submission_date,
                "url": _url
            }
Пример #2
0
class MemberItemsViewlet(browser.BungeniItemsViewlet):
    """A tab with bills, motions etc for an MP 
    (the "parliamentary activities" tab of of the "member" view)
    """
    states = _get_public_states_for( *[ ti 
        for (key, ti) in capi.iter_type_info() 
        if ti.custom and issubclass(ti.domain_model, domain.Doc) ] )
    
    render = ViewPageTemplateFile("templates/mp-item-viewlet.pt")

    def __init__(self, context, request, view, manager):
        super(MemberItemsViewlet, self).__init__(
            context, request, view, manager)
        user_id = self.context.user_id
        parliament_id = self.context.group_id
        self.query = Session().query(domain.Doc).filter(
            sql.and_(
                domain.Doc.owner_id == user_id,
                domain.Doc.parliament_id == parliament_id,
                domain.Doc.status.in_(self.states),
            ))
        #self.for_display = (self.query.count() > 0)
        self.formatter = self.get_date_formatter("date", "medium")
    
    def update(self):
        user_id = self.context.user_id
        parliament_id = self.context.group_id
        wf = capi.get_type_info("signatory").workflow
        session = Session()
        # add cosigned items
        signed_pi_ids = [sgn.head_id for sgn in
            session.query(domain.Signatory).filter(
                sql.and_(domain.Signatory.user_id == user_id,
                    domain.Signatory.status.in_(
                        wf.get_state_ids(tagged=["public"])
                    ),
                )
            ).all()
        ]
        if len(signed_pi_ids) > 0:
            self.query = self.query.union(
                session.query(domain.Doc).filter(
                    sql.and_(
                        domain.Doc.parliament_id == parliament_id,
                        domain.Doc.status.in_(self.states),
                        domain.Doc.doc_id.in_(
                            signed_pi_ids
                        )
                    )
                )
            )
        self.query = self.query.order_by(
            domain.Doc.doc_id.desc()
        )
    
    @property
    def items(self):
        for item in self.query.all():
            _url = "/business/%ss/obj-%i" % (item.type,
                item.doc_id)
            yield {"type": item.type,
                "title": item.title,
                "status": misc.get_wf_state(item),
                "submission_date" : item.submission_date,
                "url": _url }
Пример #3
0
class MemberItemsViewlet(browser.BungeniItemsViewlet):
    """A tab with bills, motions etc for an MP 
    (the "parliamentary activities" tab of of the "member" view)
    """
    states = \
        get_states("agendaitem", tagged=["public"]) + \
        get_states("bill", tagged=["public"]) + \
        get_states("motion", tagged=["public"]) + \
        get_states("question", tagged=["public"]) + \
        get_states("tableddocument", tagged=["public"])

    view_title = _("Parliamentary activities")
    view_id = "mp-items"

    # evoque
    render = z3evoque.ViewTemplateFile("viewlets.html#mp_items")

    # zpt
    #render = ViewPageTemplateFile("templates/mp_item_viewlet.pt")

    def __init__(self, context, request, view, manager):
        super(MemberItemsViewlet, self).__init__(
            context, request, view, manager)
        user_id = self.context.user_id
        parliament_id = self.context.group_id
        self.query = Session().query(domain.ParliamentaryItem).filter(
            sql.and_(
                domain.ParliamentaryItem.owner_id == user_id,
                domain.ParliamentaryItem.parliament_id == parliament_id,
                domain.ParliamentaryItem.status.in_(self.states),
            ))
        #self.for_display = (self.query.count() > 0)
        self.formatter = self.get_date_formatter("date", "medium")

    def update(self):
        user_id = self.context.user_id
        parliament_id = self.context.group_id
        session = Session()
        # add cosigned items
        signed_pi_ids = [sgn.item_id for sgn in
            session.query(domain.Signatory).filter(
                sql.and_(domain.Signatory.user_id == user_id,
                    domain.Signatory.status.in_(
                            get_states("signatory", tagged=["public"])
                        ),
                )
            ).all()
        ]
        if len(signed_pi_ids) > 0:
            self.query = self.query.union(
                session.query(domain.ParliamentaryItem).filter(
                    sql.and_(
                        domain.ParliamentaryItem.parliament_id == parliament_id,
                        domain.ParliamentaryItem.status.in_(self.states),
                        domain.ParliamentaryItem.parliamentary_item_id.in_(
                            signed_pi_ids
                        )
                    )
                )
            )
        self.query = self.query.order_by(
            domain.ParliamentaryItem.parliamentary_item_id.desc()
        )

    @property
    def items(self):
        for item in self.query.all():
            _url = "/business/%ss/obj-%i" % (item.type,
                item.parliamentary_item_id)
            yield {"type": item.type,
                "short_name": item.short_name,
                "status": misc.get_wf_state(item),
                "submission_date" : item.submission_date,
                "url": _url }