• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Branch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Branch的典型用法代码示例。如果您正苦于以下问题:Python Branch类的具体用法?Python Branch怎么用?Python Branch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: create

 def create(self, request, **kwargs):
     serializer = BranchSerializer(data=request.data)
     if serializer.is_valid():
         user = save_user(request.data, UserPermissions.IS_BRANCH)
         company = Company(**request.data["company"])
         city = City(**request.data["city"])
         branch = Branch(
             nickName=request.data["nickName"],
             type=UserType.BRANCH,
             address=request.data["address"],
             phone=request.data["phone"],
             company=company,
             city=city,
             user=user,
         )
         branch.save()
         return Response(
             {
                 "status": "SUCCESS",
                 "msg_status": "Sucursal creada satisfactoriamente. Puede ingresar con su nueva contrasena.",
             }
         )
     else:
         messages = []
         make_error(serializer.errors.values(), messages)
         return Response({"status": "FAILURE", "msg_status": messages})
开发者ID:emosquera,项目名称:ticketIntelligence,代码行数:26,代码来源:viewsets.py


示例2: BranchTestCase

class BranchTestCase(unittest.TestCase):
    
    def setUp(self):
                
        #the memcache will contain values that will break the tests
        #dont run this on production!
        memcache.flush_all()
        
        # First, create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        # Then activate the testbed, which prepares the service stubs for use.
        self.testbed.activate()
        # Create a consistency policy that will simulate the High Replication consistency model.
        self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
        # Initialize the datastore stub with this policy.
        self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)
        
        
        millis = int(round(time.time() * 1000))
        
        tree_name = 'test_tree' + str(millis)
        
        username = 'test_user' + str(millis)
        
        self.parent_branch = Branch(id=tree_name)
        
        self.parent_branch.author_name = username
        self.parent_branch.link = ''
        self.parent_branch.content = ''
        self.parent_branch.put()
        
        self.child_branchs = []
        
    def tearDown(self):
        for branch in self.child_branchs:
            branch.key.delete()
        
        self.parent_branch.key.delete()
        
        self.testbed.deactivate()
        
    def testUpdateNoDuplicate(self):
        
        
        branch = Branch()
        branch.link = 'testIdenticalLink.some_link'
        branch.content = 'some_content'
        
        branch.revision = 0
        branch.parent_branch = self.parent_branch.key
        branch.parent_branch_authorname = self.parent_branch.authorname
        branch.put()
        
        self.parent_branch.append_child(branch)
        
        self.assertTrue(len(self.parent_branch.children()) == 1)
        
        self.child_branchs.append(branch)
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:58,代码来源:data_tests.py


示例3: __init__

    def __init__(self):
        # FIXME: This function is massive. Break it up
        self._test_map = {}
        platform_id_map = {}
        branch_id_map = {}
        for test in Test.all():
            if test.hidden:
                continue

            branch_ids = [Branch.get(branch_key).id for branch_key in test.branches]
            platform_ids = [Platform.get(platform_key).id for platform_key in test.platforms]
            self._test_map[test.id] = {
                'name': test.name,
                'branchIds': branch_ids,
                'platformIds': platform_ids,
            }

            for platform_id in platform_ids:
                platform_id_map.setdefault(platform_id, {'tests': [], 'branches': []})
                platform_id_map[platform_id]['tests'].append(test.id)
                platform_id_map[platform_id]['branches'] += branch_ids

            for branch_id in branch_ids:
                branch_id_map.setdefault(branch_id, {'tests': [], 'platforms': []})
                branch_id_map[branch_id]['tests'].append(test.id)
                branch_id_map[branch_id]['platforms'] += platform_ids

        self._platform_map = {}
        for platform in Platform.all():
            if platform.id not in platform_id_map:
                continue

            if platform.hidden:
                for test_id in platform_id_map[platform.id]['tests']:
                    self._test_map[test_id]['platformIds'].remove(platform.id)
                for branch_id in platform_id_map[platform.id]['branches']:
                    branch_id_map[branch_id]['platforms'].remove(platform.id)
                continue

            self._platform_map[platform.id] = {
                'name': platform.name,
                'testIds': list(set(platform_id_map[platform.id]['tests'])),
                'branchIds': list(set(platform_id_map[platform.id]['branches'])),
            }

        self._branch_map = {}
        for branch in Branch.all():
            if branch.id not in branch_id_map:
                continue
            self._branch_map[branch.id] = {
                'name': branch.name,
                'testIds': list(set(branch_id_map[branch.id]['tests'])),
                'platformIds': list(set(branch_id_map[branch.id]['platforms'])),
            }
开发者ID:EQ4,项目名称:h5vcc,代码行数:54,代码来源:json_generators.py


示例4: setUp

 def setUp(self):
             
     #the memcache will contain values that will break the tests
     #dont run this on production!
     memcache.flush_all()
     
     # First, create an instance of the Testbed class.
     self.testbed = testbed.Testbed()
     # Then activate the testbed, which prepares the service stubs for use.
     self.testbed.activate()
     # Create a consistency policy that will simulate the High Replication consistency model.
     self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
     # Initialize the datastore stub with this policy.
     self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)
     
     
     millis = int(round(time.time() * 1000))
     
     tree_name = 'test_tree' + str(millis)
     
     username = 'test_user' + str(millis)
     
     self.parent_branch = Branch(id=tree_name)
     
     self.parent_branch.author_name = username
     self.parent_branch.link = ''
     self.parent_branch.content = ''
     self.parent_branch.put()
     
     self.child_branchs = []
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:30,代码来源:data_tests.py


示例5: get

    def get(self):
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8';
        cache = memcache.get('dashboard')
        if cache:
            self.response.out.write(cache)
            return

        webkit_trunk = Branch.get_by_key_name('webkit-trunk')

        # FIXME: Determine popular branches, platforms, and tests
        dashboard = {
            'defaultBranch': 'WebKit trunk',
            'branchToId': {webkit_trunk.name: webkit_trunk.id},
            'platformToId': {},
            'testToId': {},
        }

        for platform in Platform.all():
            dashboard['platformToId'][platform.name] = platform.id

        for test in Test.all():
            dashboard['testToId'][test.name] = test.id

        result = json.dumps(dashboard)
        self.response.out.write(result)
        memcache.add('dashboard', result)
开发者ID:sohocoke,项目名称:webkit,代码行数:26,代码来源:dashboard_handler.py


示例6: update_create

def update_create(request, id=0):
    if request.method not in ['GET', 'POST']:
        return HttpResponseNotAllowed(permitted_methods=['GET', 'POST'])
    instance = None
    if id:
        instance = get_object_or_404(Lab, pk=id)
    if request.method == 'GET':
        form = MedicalLabForm(instance)
    elif request.method == 'POST':
        form = MedicalLabForm(request.POST, instance=instance)
        if form.is_valid():
            with transaction.commit_on_success():
                lab = form.save()
                # Only add lab, main branch in new lab creation
                if not instance:
                    request.user.lab = lab
                    request.user.save()
                    Branch.create_main_branch(lab)
    return render(request, 'add_update.html', {'form':form})
开发者ID:Hamdy,项目名称:minilab,代码行数:19,代码来源:views.py


示例7: testValidator

 def testValidator(self):
 
     test_link_text = "a"*24
     test_content_text = "b"*24
     
     branch = Branch()
     branch.link = test_link_text
     branch.content = test_content_text
     branch.put()
     
     self.assertEqual(branch.link, test_link_text)
     self.assertEqual(branch.content, test_content_text)
     
     branch = Branch()
     branch.link = "<a>"+test_link_text+"</a>"
     branch.content = "<a>"+test_content_text+"</a>"
     branch.put()
     
     self.assertEqual(branch.link, test_link_text)
     self.assertEqual(branch.content, test_content_text)
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:20,代码来源:data_tests.py


示例8: get

 def get(self):
     
     trees = Tree.main_trees()
     branchdatas = Branch.get_first_branchs(trees)
     template_values = {
         'trees': trees,
         'branchdatas': branchdatas,
         'username': self.username()
     }
     
     self.render('main.html', template_values)
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:11,代码来源:handlers.py


示例9: testUpdateNoDuplicate

 def testUpdateNoDuplicate(self):
     
     
     branch = Branch()
     branch.link = 'testIdenticalLink.some_link'
     branch.content = 'some_content'
     
     branch.revision = 0
     branch.parent_branch = self.parent_branch.key
     branch.parent_branch_authorname = self.parent_branch.authorname
     branch.put()
     
     self.parent_branch.append_child(branch)
     
     self.assertTrue(len(self.parent_branch.children()) == 1)
     
     self.child_branchs.append(branch)
开发者ID:Gabicoware,项目名称:txtbranch,代码行数:17,代码来源:data_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Build类代码示例发布时间:2022-05-27
下一篇:
Python models.Box类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap