def get_user_manageable_functions(self):
     """ get user manageable functions """
     manageable_functions = self.get_manageable_functions()
     for group in self.current_user_groups:
         parts = group.id.split('_')
         if len(parts) == 1:
             continue
         group_suffix = '_'.join(parts[1:])
         if group_suffix not in manageable_functions:
             continue
         if group_suffix not in self.functions_orgs:
             self.functions_orgs[group_suffix] = []
         org = get_organization(parts[0])
         if org not in self.functions_orgs[group_suffix]:
             self.functions_orgs[group_suffix].append(
                 get_organization(parts[0]))
예제 #2
0
def finances_give_advice_states(cfg):
    """ """
    review_states = []
    for financeGroupUID in cfg.adapted().getUsedFinanceGroupIds():
        # get review_states in which advice is giveable by financeGroup
        financeGroup = get_organization(financeGroupUID)
        review_states.extend(financeGroup.get_item_advice_states(cfg))
    # manage duplicated
    return tuple(set(review_states))
예제 #3
0
 def test_idea_getIDEAPrintableItems(self):
     self.changeUser('admin')
     group = get_organization(org_id_to_uid('developers'))
     group.Title = u"Développeurs - DSI"
     self.changeUser('pmManager')
     meeting = self.create('Meeting', date='2007/12/11 09:00:00')
     item1 = self.create('MeetingItem', title='The first item')
     self.presentItem(item1)
     item2 = self.create('MeetingItem', title='The second item')
     self.presentItem(item2)
     meeting.adapted().getIDEAPrintableItemsByCategory()
예제 #4
0
 def getCustomAdviceMessageFor(self, advice):
     '''If we are on a finance advice that is still not giveable because
        the item is not 'complete', we display a clear message.'''
     item = self.getSelf()
     finance_org_uids = (finance_group_uid(), finance_group_cec_uid())
     if advice['id'] in finance_org_uids and \
        not advice['advice_addable']:
         finance_org = get_organization(advice['id'])
         tool = api.portal.get_tool('portal_plonemeeting')
         cfg = tool.getMeetingConfig(item)
         # item in state giveable but item not complete
         if item.query_state() in finance_org.get_item_advice_states(cfg):
             if not self._is_complete():
                 return {
                     'displayDefaultComplementaryMessage':
                     False,
                     'displayAdviceReviewState':
                     True,
                     'customAdviceMessage':
                     translate(
                         'finance_advice_not_giveable_because_item_not_complete',
                         domain="PloneMeeting",
                         context=item.REQUEST,
                         default=
                         "Advice is still not giveable because item is not considered complete."
                     )
                 }
             # delay still not started when advice created/proposed_to_controller
             if not item.adapted()._adviceDelayMayBeStarted(advice['id']):
                 return {
                     'displayDefaultComplementaryMessage':
                     False,
                     'displayAdviceReviewState':
                     True,
                     'customAdviceMessage':
                     translate('finance_advice_delay_still_not_started',
                               domain="PloneMeeting",
                               context=item.REQUEST,
                               default="Advice delay is still not started.")
                 }
     return {
         'displayDefaultComplementaryMessage': True,
         'displayAdviceReviewState': True,
         'customAdviceMessage': None
     }
예제 #5
0
    def __call__(self, context):
        """"""
        terms = []
        tool = api.portal.get_tool('portal_plonemeeting')
        advicePortalTypeIds = tool.getAdvicePortalTypeIds()

        # take into account groups for wich user can add an advice
        # while adding an advice, the context is his parent, aka a MeetingItem
        alterable_advice_org_uids = []
        if context.meta_type == 'MeetingItem':
            alterable_advice_org_uids = context.getAdvicesGroupsInfosForUser(
                compute_to_edit=False)[0]
        # take into account groups for which user can edit an advice
        elif context.portal_type in advicePortalTypeIds:
            alterable_advice_org_uids = context.getAdvicesGroupsInfosForUser(
                compute_to_add=False)[1]
            # make sure advice_group selected on advice is in the vocabulary
            if context.advice_group not in alterable_advice_org_uids:
                alterable_advice_org_uids.append(context.advice_group)

        # manage case where we have several meetingadvice portal_types
        # depending on current portal_type, clean up selectable orgs
        itemObj = context.meta_type == 'MeetingItem' and context or context.getParentNode(
        )
        current_portal_type = findMeetingAdvicePortalType(context)
        alterable_advice_org_uids = [
            org_uid for org_uid in alterable_advice_org_uids
            if (itemObj.adapted()._advicePortalTypeForAdviser(org_uid) ==
                current_portal_type or (
                    context.portal_type in advicePortalTypeIds
                    and org_uid == context.advice_group))
        ]

        # create vocabulary
        for alterable_advice_org_uid in alterable_advice_org_uids:
            org = get_organization(alterable_advice_org_uid)
            terms.append(
                SimpleTerm(alterable_advice_org_uid, alterable_advice_org_uid,
                           org.get_full_title()))
        return SimpleVocabulary(terms)
예제 #6
0
 def _get_organization(self, times=1, caching=True):
     ''' '''
     for time in range(times):
         get_organization(self.vendors_uid, caching=caching)
예제 #7
0
 def test_get_organization(self):
     suffixed_org = get_plone_group_id(self.uid, 'suffix')
     # get_organization may receive a plone_group_id or an organization uid
     self.assertEqual(get_organization(suffixed_org), self.dep1)
     self.assertEqual(get_organization(self.uid), self.dep1)