예제 #1
0
    def getMenuItems(self, context, request):
        """Return menu item entries in a TAL-friendly form."""
        if interfaces.IBusinessWhatsOnSectionLayer.providedBy(request):
            return ()
        else:
            if IBungeniApplication.providedBy(context.__parent__):
                return ()
        wf = IWorkflow(context, None)
        if wf is None:
            return ()
        #state = IWorkflowInfo(context).state().getState()
        wf_info = IWorkflowInfo(context)
        transitions = wf_info.getManualTransitionIds()

        # !+ context_workflow menu: the order of transitions is alphabetic, but
        # should really be order of definition.
        parliament_id = getCurrentParliamentId()

        url = ui_url.absoluteURL(context, request)
        site_url2 = ui_url.absoluteURL(getSite(), request)
        results = []
        for transition in transitions:
            tid = transition
            state_transition = wf.getTransitionById(transition)
            #Compares the current url to homepage to determine whether we are on workspace or not.
            #Fix for bug 319
            #Someone should probably review this.
            if url == site_url2:
                transition_url = site_url2 + \
                             '/archive/browse/parliaments/obj-' + str(parliament_id) + \
                             '/change_workflow_state?' + \
                             'transition=%s&next_url=...' % tid
            else:
                transition_url = url + \
                             '/change_workflow_state?'\
                             'transition=%s&next_url=...' % tid
            extra = {
                'id': 'workflow-transition-%s' % tid,
                'separator': None,
                'class': ''
            }

            state_title = translate(str(state_transition.title),
                                    domain="bungeni.core",
                                    context=request)
            results.append(
                dict(title=state_title,
                     description="",
                     action=transition_url,
                     selected=False,
                     transition_id=tid,
                     icon=None,
                     extra=extra,
                     submenu=None))

        return results
예제 #2
0
 def getMenuItems(self, context, request):
     """Return menu item entries in a TAL-friendly form."""
     if interfaces.IBusinessWhatsOnSectionLayer.providedBy(request):
         return ()
     else:
         if IBungeniApplication.providedBy(context.__parent__):
             return ()
     wf = IWorkflow(context, None)
     if wf is None:
         return ()
     #state = IWorkflowInfo(context).state().getState()
     wf_info = IWorkflowInfo(context)
     transitions = wf_info.getManualTransitionIds()
     
     # !+ context_workflow menu: the order of transitions is alphabetic, but 
     # should really be order of definition.
     parliament_id = getCurrentParliamentId()
     
     _url = url.absoluteURL(context, request)
     site_url2 = url.absoluteURL(getSite(), request)
     results = []
     for transition in transitions:
         tid = transition
         state_transition = wf.getTransitionById(transition)
         #Compares the current url to homepage to determine whether we are on workspace or not.
         #Fix for bug 319
         #Someone should probably review this.
         if _url == site_url2:
             transition_url = site_url2 + \
                          "/archive/browse/parliaments/obj-" + str(parliament_id) + \
                          "/change_workflow_state?" + \
                          "transition=%s&next_url=..." % tid
         else:
             transition_url = _url + \
                          "/change_workflow_state?"\
                          "transition=%s&next_url=..." % tid
         extra = {"id": "workflow-transition-%s" % tid,
                  "separator": None,
                  "class": ""}
         
         state_title = translate(str(state_transition.title), 
                 domain="bungeni.core", 
                 context=request)
         results.append(
             dict(title=state_title,
                  description="",
                  action=transition_url,
                  selected=False,
                  transition_id=tid,
                  icon=None,
                  extra=extra,
                  submenu=None))
     
     return results
예제 #3
0
 def __new__(cls, context, request):
     # this is currently the only way to make sure this menu only
     # "adapts" to a workflowed context; the idea is that the
     # component lookup will fail, which will propagate back to the
     # original lookup request
     workflow = IWorkflow(context, None)
     if workflow is None:
         return
     return object.__new__(cls, context, request)
예제 #4
0
def fireAutomaticTransitions( object, event ):
    """ fire automatic transitions for a new state """
    
    if IWorkflow(object, None) is None:
        return
    
    workflow = IWorkflowInfo(object, None)
    if workflow is not None:
        workflow.fireAutomatic()
예제 #5
0
def initializeWorkflow( object, event):
    """ in response to object created events """

    if IWorkflow(object, None) is None:
        return
    
    workflow = IWorkflowInfo(object, None)
    if workflow is not None:
        workflow.fireAutomatic()
예제 #6
0
    def update(self):
        need('yui-dragdrop')
        need('yui-container')

        session = Session()
        group_id = self.get_group_id()

        items = tuple(
            session.query(self.model).filter(
                sql.and_(self.model.status.in_(self.states),
                         self.model.group_id == group_id)))
        sitting = self._parent._parent.context
        scheduled_item_ids = [item.item_id for item in sitting.item_schedule]
        # add location to items
        gsm = component.getSiteManager()
        adapter = gsm.adapters.lookup(
            (interface.implementedBy(self.model), interface.providedBy(self)),
            ILocation)

        items = [adapter(item, None) for item in items]

        # for each item, format dictionary for use in template
        self.items = [
            {
                'title':
                properties.title,
                'name':
                item.__class__.__name__,
                'description':
                properties.description,
                #'date': _(u"$F", mapping={'F':
                #           datetimedict.fromdatetime(item.changes[-1].date)}),
                'date':
                item.changes[-1].date_active,
                'state':
                _(IWorkflow(item).workflow.states[item.status].title),
                'id':
                item.parliamentary_item_id,
                'class': (item.parliamentary_item_id in scheduled_item_ids)
                and "dd-disable" or "",
                'url':
                url.set_url_context(url.absoluteURL(item, self.request))
            }
            for (item,
                 properties) in [(item,
                                  (IDCDescriptiveProperties.providedBy(item)
                                   and item or IDCDescriptiveProperties(item)))
                                 for item in items]
        ]
예제 #7
0
    def update(self):
        need("yui-dragdrop")
        need("yui-container")

        sitting = self._parent._parent.context
        scheduled_item_ids = [item.item_id for item in sitting.item_schedule]

        # add location to items
        gsm = component.getSiteManager()
        adapter = gsm.adapters.lookup(
            (interface.implementedBy(self.model), interface.providedBy(self)),
            ILocation)

        date_formatter = self.get_date_formatter("date", "medium")
        items = [adapter(item, None) for item in self._query_items()]
        # for each item, format dictionary for use in template
        self.items = [
            {
                "title":
                properties.title,
                "name":
                item.__class__.__name__,
                "description":
                properties.description,
                #"date": _(u"$F", mapping={"F":
                #       datetimedict.fromdatetime(item.changes[-1].date)}),
                #"date":item.changes[-1].date,
                # not every item has a auditlog (headings)
                # use last status change instead.
                "date":
                date_formatter.format(self._item_date(item)),
                "state":
                IWorkflow(item).workflow.states[item.status].title,
                "id":
                item.parliamentary_item_id,
                "class": ((item.parliamentary_item_id in scheduled_item_ids
                           and "dd-disable") or ""),
                "url":
                self._item_url(item)
            } for item, properties in [(
                item, (IDCDescriptiveProperties.providedBy(item) and item
                       or IDCDescriptiveProperties(item))) for item in items]
        ]
예제 #8
0
    def update(self):
        need('yui-dragdrop')
        need('yui-container')
        session = Session()
        items = tuple(
            session.query(self.model).filter(self.model.status.in_(
                self.states)))

        sitting = self._parent._parent.context
        scheduled_item_ids = [item.item_id for item in sitting.item_schedule]

        # add location to items
        gsm = component.getSiteManager()
        adapter = gsm.adapters.lookup(
            (interface.implementedBy(self.model), interface.providedBy(self)),
            ILocation)

        items = [adapter(item, None) for item in items]
        site_url = url.absoluteURL(getSite(), self.request)
        # for each item, format dictionary for use in template
        self.items = [{
            'title': properties.title,
            'name': item.__class__.__name__,
            'description': properties.description,
            #            'date': _(u"$F", mapping={"F":
            #                      datetimedict.fromdatetime(item.changes[-1].date)}),
            #'date':item.changes[-1].date,
            # not every item has a auditlog (headings) use last status change instead.
            'date':item.status_date,
            #
            'state': IWorkflow(item).workflow.states[item.status].title,
            'id': item.parliamentary_item_id,
            'class': (item.parliamentary_item_id in scheduled_item_ids) and "dd-disable" or "",
            'url': url.set_url_context(site_url+('/business/%ss/obj-%s' % (item.type, item.parliamentary_item_id)))
            } for item, properties in \
            [(item, (IDCDescriptiveProperties.providedBy(item) and item or \
            IDCDescriptiveProperties(item))) for
             item in items]]
예제 #9
0
def list_permissions(item):
    wf = IWorkflow(item)
    info = IWorkflowInfo(item)
    state = info.state().getState()
    return tuple(transition.permission 
                for transition in wf.getTransitions(state))