示例#1
0
 def test_getLastWFAction(self):
     """Test the utils.getLastWFAction method.
        It should return the action passed in parameter for the workflow_history.
        It is a shortcut using utils.getLastAction."""
     doc = api.content.create(type='Document',
                              id='doc',
                              container=self.portal)
     # publish the doc so we have an new event in the workflow_history
     api.content.transition(doc, 'publish', comment='Publication comment')
     self.assertEqual(getLastWFAction(doc)['action'], 'publish')
     # same as getting action with that name
     publish_action = getLastWFAction(doc, transition='publish')
     self.assertEqual(publish_action['action'], 'publish')
     self.assertEqual(publish_action['comments'], 'Publication comment')
示例#2
0
 def _financialAdviceDetails(self):
     '''Get the financial advice signature date, advice type and comment'''
     res = {}
     tool = api.portal.get_tool('portal_plonemeeting')
     cfg = tool.getMeetingConfig(self.context)
     financialAdvice = cfg.adapted().getUsedFinanceGroupIds()[0]
     adviceData = self.context.getAdviceDataFor(self.context.context,
                                                financialAdvice)
     res['comment'] = 'comment' in adviceData\
         and adviceData['comment'] or ''
     advice_id = 'advice_id' in adviceData\
         and adviceData['advice_id'] or ''
     signature_event = advice_id and getLastWFAction(
         getattr(self.context, advice_id), 'signFinancialAdvice') or ''
     res['out_of_financial_dpt'] = 'time' in signature_event and signature_event[
         'time'] or ''
     res['out_of_financial_dpt_localized'] = res['out_of_financial_dpt']\
         and res['out_of_financial_dpt'].strftime('%d/%m/%Y') or ''
     # "positive_with_remarks_finance" will be printed "positive_finance"
     if adviceData['type'] == 'positive_with_remarks_finance':
         type_translated = self.translate(
             msgid='positive_finance',
             domain='PloneMeeting').encode('utf-8')
     else:
         type_translated = adviceData['type_translated'].encode('utf-8')
     res['advice_type'] = '<p><u>Type d\'avis:</u>  %s</p>' % type_translated
     res['delay_started_on_localized'] = 'delay_started_on_localized' in adviceData['delay_infos']\
         and adviceData['delay_infos']['delay_started_on_localized'] or ''
     res['delay_started_on'] = 'delay_started_on' in adviceData\
         and adviceData['delay_started_on'] or ''
     return res
示例#3
0
 def test_CouncilItemsUsingSpecialCategoriesAreInsertedAsNormalItem(self):
     """ """
     # use the Council demo that adds items using special category in a frozen meeting
     meeting = self.setupCouncilDemoData()
     self.changeUser('pmManager')
     self.assertEqual(meeting.queryState(), 'frozen')
     special_items = meeting.getItems(ordered=True,
                                      additional_catalog_query={
                                          'getCategory':
                                          COUNCIL_SPECIAL_CATEGORIES
                                      })
     # items were presented after meeting freeze
     for item in special_items:
         self.assertTrue(
             item.modified() > getLastWFAction(meeting, 'freeze')['time'])
     self.assertEqual(
         [(item.getListType(), item.getCategory(), item.getPrivacy())
          for item in special_items],
         [('normal', 'proposition-de-motion', 'public'),
          ('normal', 'proposition-de-motion', 'public'),
          ('normal', 'proposes-par-un-conseiller', 'public'),
          ('normal', 'proposes-par-un-conseiller', 'public'),
          ('normal', 'interventions', 'public'),
          ('normal', 'questions-actualite', 'public'),
          ('normal', 'questions-actualite', 'public'),
          ('normal', 'questions-actualite', 'public')])
示例#4
0
 def _collegeAdministrativeReviewer(self):
     """Used on a council item : get the administrative reviewer of the College item."""
     collegeItem = self.context.adapted().getItemCollege()
     if collegeItem:
         event = getLastWFAction(collegeItem, 'proposeToDirector')
         if event:
             return api.user.get(event['actor'])
示例#5
0
def previous_review_state(obj):
    """
      Indexes the previous review_state, aka the review_state before current review_state
    """
    previous_action = None
    event = getLastWFAction(obj, transition='before_last')
    if event:
        previous_action = event['review_state']
    return previous_action or _marker
示例#6
0
 def get_advice_given_on(self):
     '''Return the date the advice was given on.
        Returns the smallest date between modified() and last event 'giveAdvice'.
        This manages case when advice is edited after it is given, for example
        when a MeetingManager corrects a typo, the advice_given_on date will be
        the 'giveAdvice' date.'''
     lastEvent = getLastWFAction(self, 'giveAdvice')
     modified = self.modified()
     if not lastEvent:
         return modified
     else:
         return min(lastEvent['time'], modified)
示例#7
0
 def printLastEventFor(self, transition):
     """print user who have the last action for this item"""
     lastEvent = getLastWFAction(self.context, transition=transition)
     if lastEvent:
         mTool = api.portal.get_tool('portal_membership')
         author_id = str(lastEvent['actor'])
         author = mTool.getMemberById(author_id)
         return {
             'author': author and author.getProperty('fullname')
             or author_id,
             'date': lastEvent['time'].strftime('%d/%m/%Y %H:%M')
         }
     return ''
示例#8
0
 def _recompute_items_order(self):
     """Get every items and order it by get_item_insert_order."""
     items = self.context.get_items(ordered=True)
     tool = api.portal.get_tool('portal_plonemeeting')
     cfg = tool.getMeetingConfig(self.context)
     # sort items by insertOrder then by date it was presented
     # so items with same insert order will be sorted by WF transition 'present' time
     items = sorted([(self.context.get_item_insert_order(item, cfg),
                      getLastWFAction(item, 'present')['time'], item)
                     for item in items])
     # get items
     items = [item[2] for item in items]
     # set items itemNumber
     itemNumber = 100
     for item in items:
         item.setItemNumber(itemNumber)
         itemNumber = itemNumber + 100
     self.context._finalize_item_insert(items_to_update=items)
示例#9
0
    def _getWorkFlowAdviceTransmissionDate(self):
        """
        :return: The date as a string when the finance service received the advice request if no legal delay applies.
        """

        tool = api.portal.get_tool('portal_plonemeeting')
        cfg = tool.getMeetingConfig(self.context)

        wf_present_transition = list(cfg.getTransitionsForPresentingAnItem())
        item_advice_states = cfg.itemAdviceStates

        if 'itemfrozen' in item_advice_states and 'itemfreeze' not in wf_present_transition:
            wf_present_transition.append('itemfreeze')

        for item_transition in wf_present_transition:
            event = getLastWFAction(self.context, item_transition)
            if event and 'review_state' in event and event[
                    'review_state'] in item_advice_states:
                return event['time']

        return None