当前位置: 首页>>代码示例>>Python>>正文


Python Flow.create方法代码示例

本文整理汇总了Python中temba.flows.models.Flow.create方法的典型用法代码示例。如果您正苦于以下问题:Python Flow.create方法的具体用法?Python Flow.create怎么用?Python Flow.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在temba.flows.models.Flow的用法示例。


在下文中一共展示了Flow.create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_flow

# 需要导入模块: from temba.flows.models import Flow [as 别名]
# 或者: from temba.flows.models.Flow import create [as 别名]
    def create_flow(self):
        start = int(time.time()*1000) % 1000000

        definition = dict(action_sets=[dict(uuid=uuid(start + 1), x=1, y=1, destination=uuid(start + 5),
                                            actions=[dict(type='reply', msg='What is your favorite color?')]),
                                       dict(uuid=uuid(start + 2), x=2, y=2, destination=None,
                                            actions=[dict(type='reply', msg='I love orange too!')]),
                                       dict(uuid=uuid(start + 3), x=3, y=3, destination=None,
                                            actions=[dict(type='reply', msg='Blue is sad. :(')]),
                                       dict(uuid=uuid(start + 4), x=4, y=4, destination=None,
                                            actions=[dict(type='reply', msg='That is a funny color.')])
                                       ],
                          rule_sets=[dict(uuid=uuid(start + 5), x=5, y=5,
                                          label='color',
                                          response_type='C',
                                          rules=[
                                              dict(uuid=uuid(start + 12), destination=uuid(start + 2), test=dict(type='contains', test='orange'), category="Orange"),
                                              dict(uuid=uuid(start + 13), destination=uuid(start + 3), test=dict(type='contains', test='blue'), category="Blue"),
                                              dict(uuid=uuid(start + 14), destination=uuid(start + 4), test=dict(type='true'), category="Other"),
                                              dict(uuid=uuid(start + 15), test=dict(type='true'), category="Nothing")]) # test case with no destination
                                    ],
                          entry=uuid(start + 1))

        flow = Flow.create(self.org, self.admin, "Color Flow")
        flow.update(definition)
        return flow
开发者ID:AxisOfEval,项目名称:rapidpro,代码行数:28,代码来源:tests.py

示例2: create_flow

# 需要导入模块: from temba.flows.models import Flow [as 别名]
# 或者: from temba.flows.models.Flow import create [as 别名]
    def create_flow(self, uuid_start=None, **kwargs):
        if 'org' not in kwargs:
            kwargs['org'] = self.org
        if 'user' not in kwargs:
            kwargs['user'] = self.user
        if 'name' not in kwargs:
            kwargs['name'] = "Color Flow"

        flow = Flow.create(**kwargs)
        flow.update(self.create_flow_definition(uuid_start))
        return Flow.objects.get(pk=flow.pk)
开发者ID:MOconcepts,项目名称:rapidpro,代码行数:13,代码来源:tests.py

示例3: test_icon

# 需要导入模块: from temba.flows.models import Flow [as 别名]
# 或者: from temba.flows.models.Flow import create [as 别名]
    def test_icon(self):
        from temba.campaigns.models import Campaign
        from temba.triggers.models import Trigger
        from temba.flows.models import Flow
        from temba.utils.templatetags.temba import icon

        campaign = Campaign.create(self.org, self.admin, 'Test Campaign', self.create_group('Test group', []))
        flow = Flow.create(self.org, self.admin, 'Test Flow')
        trigger = Trigger.objects.create(org=self.org, keyword='trigger', flow=flow, created_by=self.admin, modified_by=self.admin)

        self.assertEquals('icon-instant', icon(campaign))
        self.assertEquals('icon-feed', icon(trigger))
        self.assertEquals('icon-tree', icon(flow))
        self.assertEquals("", icon(None))
开发者ID:Spring-Apps,项目名称:rapidpro,代码行数:16,代码来源:tests.py

示例4: create_flow

# 需要导入模块: from temba.flows.models import Flow [as 别名]
# 或者: from temba.flows.models.Flow import create [as 别名]
    def create_flow(self, definition=None, **kwargs):
        if "org" not in kwargs:
            kwargs["org"] = self.org
        if "user" not in kwargs:
            kwargs["user"] = self.user
        if "name" not in kwargs:
            kwargs["name"] = "Color Flow"

        flow = Flow.create(**kwargs)
        if not definition:
            # if definition isn't provided, generate simple single message flow
            node_uuid = str(uuid4())
            definition = {
                "version": 10,
                "flow_type": "F",
                "base_language": "eng",
                "entry": node_uuid,
                "action_sets": [
                    {
                        "uuid": node_uuid,
                        "x": 0,
                        "y": 0,
                        "actions": [
                            {"msg": {"eng": "Hey everybody!"}, "media": {}, "send_all": False, "type": "reply"}
                        ],
                        "destination": None,
                    }
                ],
                "rule_sets": [],
            }

        flow.version_number = definition["version"]
        flow.save()

        json_flow = FlowRevision.migrate_definition(definition, flow)
        flow.update(json_flow)

        return flow
开发者ID:mxabierto,项目名称:rapidpro,代码行数:40,代码来源:base.py

示例5: get_flow

# 需要导入模块: from temba.flows.models import Flow [as 别名]
# 或者: from temba.flows.models.Flow import create [as 别名]
 def get_flow(self, filename, substitutions=None):
     flow = Flow.create(self.org, self.admin, name=filename)
     self.update_flow(flow, filename, substitutions)
     return flow
开发者ID:AxisOfEval,项目名称:rapidpro,代码行数:6,代码来源:tests.py

示例6: create_flow

# 需要导入模块: from temba.flows.models import Flow [as 别名]
# 或者: from temba.flows.models.Flow import create [as 别名]
 def create_flow(self, uuid_start=None):
     flow = Flow.create(self.org, self.admin, "Color Flow")
     flow.update(self.create_flow_definition(uuid_start))
     return Flow.objects.get(pk=flow.pk)
开发者ID:mbanje,项目名称:rapidpro,代码行数:6,代码来源:tests.py


注:本文中的temba.flows.models.Flow.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。