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


Python Corporation.by_uuid方法代码示例

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


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

示例1: edit_corporations

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import by_uuid [as 别名]
 def edit_corporations(self):
     ''' Updates corporation object in the database '''
     form = Form(
         uuid="Object not selected",
         name="Missing corporation name",
         description="Missing description",
     )
     if form.validate(self.request.arguments):
         corp = Corporation.by_uuid(self.get_argument('uuid'))
         if corp is not None:
             if self.get_argument('name') != corp.name:
                 logging.info("Updated corporation name %s -> %s" %
                     (corp.name, self.get_argument('name'),)
                 )
                 corp.name = unicode(self.get_argument('name'))
             if self.get_argument('description') != corp.description:
                 logging.info("Updated corporation description %s -> %s" %
                     (corp.description, self.get_argument('description'),)
                 )
                 corp.description = unicode(self.get_argument('description'))
             dbsession.add(corp)
             dbsession.flush()
             self.redirect('/admin/view/game_objects')
         else:
             self.render("admin/view/game_objects.html",
                 errors=["Corporation does not exist"]
             )
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:31,代码来源:AdminHandlers.py

示例2: create_box

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import by_uuid [as 别名]
 def create_box(self):
     ''' Create a box object '''
     form = Form(
         box_name="Enter a box name",
         description="Enter a description",
         difficulty="Select a difficulty",
         corporation_uuid="Please select a corporation",
         game_level="Please select a game level",
     )
     if form.validate(self.request.arguments):
         try:
             game_level = int(self.get_argument('game_level'))
             corp_uuid = self.get_argument('corporation_uuid')
             if Box.by_name(self.get_argument('box_name')) is not None:
                 self.render("admin/create/box.html",
                     errors=["Box name already exists"]
                 )
             elif Corporation.by_uuid(corp_uuid) is None:
                 self.render("admin/create/box.html",
                     errors=["Corporation does not exist"]
                 )
             elif GameLevel.by_number(game_level) is None:
                 self.render("admin/create/box.html",
                     errors=["Game level does not exist"]
                 )
             else:
                 self.__mkbox__()
                 self.redirect('/admin/view/game_objects')
         except ValueError:
             self.render('admin/view/create.html',
                 errors=["Invalid level number"]
             )
     else:
         self.render("admin/create/box.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:36,代码来源:AdminHandlers.py

示例3: __mkbox__

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import by_uuid [as 别名]
 def __mkbox__(self):
     ''' Creates a box in the database '''
     corp = Corporation.by_uuid(self.get_argument('corporation_uuid'))
     level = GameLevel.by_number(int(self.get_argument('game_level')))
     box = Box(
         name=unicode(self.get_argument('box_name')),
         description=unicode(self.get_argument('description')),
         difficulty=unicode(self.get_argument('difficulty')),
         corporation_id=corp.id,
         game_level_id=level.id,
     )
     dbsession.add(box)
     dbsession.flush()
开发者ID:mach327,项目名称:RootTheBox,代码行数:15,代码来源:AdminHandlers.py

示例4: edit_boxes

# 需要导入模块: from models import Corporation [as 别名]
# 或者: from models.Corporation import by_uuid [as 别名]
 def edit_boxes(self):
     ''' Edit existing boxes in the database '''
     form = Form(
         uuid="Object not selected",
         name="Missing box name",
         corporation_uuid="Please select a corporation",
         description="Please enter a description",
         difficulty="Please enter a difficulty",
     )
     if form.validate(self.request.arguments):
         box = Box.by_uuid(self.get_argument('uuid'))
         if box is not None:
             errors = []
             if self.get_argument('name') != box.name:
                 if Box.by_name(self.get_argument('name')) is None:
                     logging.info("Updated box name %s -> %s" %
                         (box.name, self.get_argument('name'),)
                     )
                     box.name = unicode(self.get_argument('name'))
                 else:
                     errors.append("Box name already exists")
             corp = Corporation.by_uuid(self.get_argument('corporation_uuid'))
             if corp is not None and corp.id != box.corporation_id:
                 logging.info("Updated %s's corporation %s -> %s" %
                     (box.name, box.corporation_id, corp.id,))
                 box.corporation_id = corp.id
             elif corp is None:
                 errors.append("Corporation does not exist")
             if self.get_argument('description') != box.description:
                 logging.info("Updated %s's description %s -> %s" %
                     (box.name, box.description, self.get_argument('description'),)
                 )
                 box.description = unicode(self.get_argument('description'))
             if self.get_argument('difficulty') != box.difficulty:
                 logging.info("Updated %s's difficulty %s -> %s" %
                     (box.name, box.difficulty, self.get_argument('difficulty'),)
                 )
                 box.difficulty = unicode(self.get_argument('difficulty'))
             dbsession.add(box)
             dbsession.flush()
             self.render("admin/view/game_objects.html", errors=errors)
         else:
             self.render("admin/view/game_objects.html",
                 errors=["Box does not exist"]
             )
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:49,代码来源:AdminHandlers.py


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