當前位置: 首頁>>代碼示例>>Python>>正文


Python ProceedingService.get_available_proceedings方法代碼示例

本文整理匯總了Python中river.services.proceeding.ProceedingService.get_available_proceedings方法的典型用法代碼示例。如果您正苦於以下問題:Python ProceedingService.get_available_proceedings方法的具體用法?Python ProceedingService.get_available_proceedings怎麽用?Python ProceedingService.get_available_proceedings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在river.services.proceeding.ProceedingService的用法示例。


在下文中一共展示了ProceedingService.get_available_proceedings方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_proceedings_object_waiting_for_approval_without_skip

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
    def test_get_proceedings_object_waiting_for_approval_without_skip(self):
        ObjectService.register_object(self.objects[0], self.field)
        ObjectService.register_object(self.objects[1], self.field)

        proceedings = ProceedingService.get_available_proceedings(self.objects[0], self.field, [self.objects[0].my_field], user=self.user1)
        self.assertEqual(1, proceedings.count())

        proceedings = ProceedingService.get_available_proceedings(self.objects[0], self.field, [self.objects[0].my_field], user=self.user2)
        self.assertEqual(0, proceedings.count())

        proceedings = ProceedingService.get_available_proceedings(self.objects[0], self.field, [self.objects[0].my_field], user=self.user3)
        self.assertEqual(0, proceedings.count())

        proceedings = ProceedingService.get_available_proceedings(self.objects[0], self.field, [self.objects[0].my_field], user=self.user4)
        self.assertEqual(0, proceedings.count())
開發者ID:pombredanne,項目名稱:django-river,代碼行數:17,代碼來源:test__proceeding_service.py

示例2: process

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
        def process(workflow_object, field, user, action, next_state=None, god_mod=False):
            current_state = getattr(workflow_object, field)
            proceedings = ProceedingService.get_available_proceedings(workflow_object, field, [current_state],
                                                                      user=user, god_mod=god_mod)
            c = proceedings.count()
            if c == 0:
                raise RiverException(ErrorCode.NO_AVAILABLE_NEXT_STATE_FOR_USER,
                                     "There is no available state for destination for the user.")
            if c > 1:
                if next_state:
                    proceedings = proceedings.filter(meta__transition__destination_state=next_state)
                    if proceedings.count() == 0:
                        available_states = StateService.get_available_states(workflow_object, field, user)
                        raise RiverException(ErrorCode.INVALID_NEXT_STATE_FOR_USER,
                                             "Invalid state is given(%s). Valid states is(are) %s" % (
                                                 next_state.__unicode__(),
                                                 ','.join([ast.__unicode__() for ast in available_states])))
                else:
                    raise RiverException(ErrorCode.NEXT_STATE_IS_REQUIRED,
                                         "State must be given when there are multiple states for destination")
            proceeding = proceedings[0]
            proceeding.status = action
            proceeding.transactioner = user
            proceeding.transaction_date = datetime.now()
            if workflow_object.proceeding:
                proceeding.previous = workflow_object.proceeding
            proceeding.save()


            return proceeding
開發者ID:DjangoBD,項目名稱:django-river,代碼行數:32,代碼來源:transition.py

示例3: proceed

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
    def proceed(workflow_object, field, user, next_state=None, god_mod=False):

        def process(workflow_object, field, user, action, next_state=None, god_mod=False):
            current_state = getattr(workflow_object, field)
            proceedings = ProceedingService.get_available_proceedings(workflow_object, field, [current_state],
                                                                      user=user, god_mod=god_mod)
            c = proceedings.count()
            if c == 0:
                raise RiverException(ErrorCode.NO_AVAILABLE_NEXT_STATE_FOR_USER,
                                     "There is no available state for destination for the user.")
            if c > 1:
                if next_state:
                    proceedings = proceedings.filter(meta__transition__destination_state=next_state)
                    if proceedings.count() == 0:
                        available_states = StateService.get_available_states(workflow_object, field, user)
                        raise RiverException(ErrorCode.INVALID_NEXT_STATE_FOR_USER,
                                             "Invalid state is given(%s). Valid states is(are) %s" % (
                                                 next_state.__unicode__(),
                                                 ','.join([ast.__unicode__() for ast in available_states])))
                else:
                    raise RiverException(ErrorCode.NEXT_STATE_IS_REQUIRED,
                                         "State must be given when there are multiple states for destination")
            proceeding = proceedings[0]
            proceeding.status = action
            proceeding.transactioner = user
            proceeding.transaction_date = datetime.now()
            if workflow_object.proceeding:
                proceeding.previous = workflow_object.proceeding
            proceeding.save()


            return proceeding

        proceeding = process(workflow_object, field, user, APPROVED, next_state, god_mod)

        current_state = getattr(workflow_object, field)

        # Any other proceeding is left?
        required_proceedings = ProceedingService.get_available_proceedings(workflow_object, field, [current_state],
                                                                           destination_state=next_state,
                                                                           god_mod=god_mod)

        transition_status = False
        if required_proceedings.count() == 0:
            setattr(workflow_object, field, proceeding.meta.transition.destination_state)
            transition_status = True

            # Next states should be PENDING back again if there is circle.
            ProceedingService.cycle_proceedings(workflow_object, field)
            # ProceedingService.get_next_proceedings(workflow_object, field).update(status=PENDING)

        with ProceedingSignal(workflow_object, field, proceeding), TransitionSignal(transition_status,
                                                                                    workflow_object, field,
                                                                                    proceeding), FinalSignal(
            workflow_object, field):
            workflow_object.save()

        LOGGER.debug("Workflow object %s for field %s is proceeded for next transition. Transition: %s -> %s" % (
            workflow_object, field, current_state.label, getattr(workflow_object, field).label))
開發者ID:DjangoBD,項目名稱:django-river,代碼行數:61,代碼來源:transition.py

示例4: get_objects_waiting_for_approval

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
 def get_objects_waiting_for_approval(content_type, user):
     object_pks = []
     WorkflowObjectClass = content_type.model_class()
     for workflow_object in WorkflowObjectClass.objects.all():
         proceedings = ProceedingService.get_available_proceedings(workflow_object, [workflow_object.get_state()], user=user)
         if proceedings.count():
             object_pks.append(workflow_object.pk)
     return WorkflowObjectClass.objects.filter(pk__in=object_pks)
開發者ID:javrasya,項目名稱:django-river,代碼行數:10,代碼來源:object.py

示例5: test_get_proceedings_object_waiting_for_approval_with_skip

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
    def test_get_proceedings_object_waiting_for_approval_with_skip(self):
        self.initialize_normal_scenario()

        ObjectService.register_object(self.objects[0], self.field)
        ObjectService.register_object(self.objects[1], self.field)

        proceedings = self.objects[1].get_available_proceedings(self.user1)
        self.assertEqual(1, proceedings.count())
        self.assertEqual(State.objects.get(label='s2'), proceedings[0].meta.transition.destination_state)

        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state=State.objects.get(label='s2')
        ).update(skip=True)

        proceedings = ProceedingService.get_available_proceedings(self.objects[1], self.field,
                                                                  [self.objects[1].my_field], user=self.user2)
        self.assertEqual(1, proceedings.count())
        self.assertEqual(State.objects.get(label='s3'), proceedings[0].meta.transition.destination_state)

        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state=State.objects.get(label='s3')
        ).update(skip=True)

        proceedings = ProceedingService.get_available_proceedings(self.objects[1], self.field,
                                                                  [self.objects[1].my_field], user=self.user4)
        self.assertEqual(2, proceedings.count())
        self.assertEqual(State.objects.get(label='s4'), proceedings[0].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s5'), proceedings[1].meta.transition.destination_state)

        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state=State.objects.get(label='s4')
        ).update(skip=True)

        proceedings = ProceedingService.get_available_proceedings(self.objects[1], self.field,
                                                                  [self.objects[1].my_field], user=self.user4)
        self.assertEqual(3, proceedings.count())
        self.assertEqual(State.objects.get(label='s5'), proceedings[0].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s4.1'), proceedings[1].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s4.2'), proceedings[2].meta.transition.destination_state)

        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state=State.objects.get(label='s4')
        ).update(skip=False)
        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state=State.objects.get(label='s5')
        ).update(skip=True)

        proceedings = ProceedingService.get_available_proceedings(self.objects[1], self.field,
                                                                  [self.objects[1].my_field], user=self.user4)
        self.assertEqual(3, proceedings.count())
        self.assertEqual(State.objects.get(label='s4'), proceedings[0].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s5.1'), proceedings[1].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s5.2'), proceedings[2].meta.transition.destination_state)

        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state__in=State.objects.filter(label__in=['s4', 's5'])
        ).update(skip=True)

        proceedings = ProceedingService.get_available_proceedings(self.objects[1], self.field,
                                                                  [self.objects[1].my_field], user=self.user4)
        self.assertEqual(4, proceedings.count())
        self.assertEqual(State.objects.get(label='s4.1'), proceedings[0].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s4.2'), proceedings[1].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s5.1'), proceedings[2].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s5.2'), proceedings[3].meta.transition.destination_state)

        Proceeding.objects.filter(
            field=self.field,
            workflow_object=self.objects[1],
            meta__transition__destination_state__in=State.objects.filter(label__in=['s4.1', 's5.1'])
        ).update(skip=True)

        proceedings = ProceedingService.get_available_proceedings(self.objects[1], self.field,
                                                                  [self.objects[1].my_field], user=self.user4)
        self.assertEqual(2, proceedings.count())
        self.assertEqual(State.objects.get(label='s4.2'), proceedings[0].meta.transition.destination_state)
        self.assertEqual(State.objects.get(label='s5.2'), proceedings[1].meta.transition.destination_state)
開發者ID:DjangoBD,項目名稱:django-river,代碼行數:91,代碼來源:test__proceeding_service.py

示例6: get_available_proceedings

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
        def get_available_proceedings(self, *args, **kwargs):
            from river.services.proceeding import ProceedingService

            return ProceedingService.get_available_proceedings(self, name, [getattr(self, name)], *args, **kwargs)
開發者ID:pombredanne,項目名稱:django-river,代碼行數:6,代碼來源:state.py

示例7: get_available_proceedings

# 需要導入模塊: from river.services.proceeding import ProceedingService [as 別名]
# 或者: from river.services.proceeding.ProceedingService import get_available_proceedings [as 別名]
        def get_available_proceedings(self, *args, **kwargs):
            from river.services.proceeding import ProceedingService

            return ProceedingService.get_available_proceedings(self, [self.get_state()], *args, **kwargs)
開發者ID:javrasya,項目名稱:django-river,代碼行數:6,代碼來源:state.py


注:本文中的river.services.proceeding.ProceedingService.get_available_proceedings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。