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


Python Group.query方法代码示例

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


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

示例1: _get_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
 def _get_group(self, group_id=None, group_name=None):
     if group_id is not None:
         return Group.query(
             ndb.AND(
                 Group.unique_id == group_id
             )
         ).get()
     else:
         return Group.query(
             ndb.AND(
                 Group.name == group_name,
                 Group.user == self.user_key
             )
         ).get()
开发者ID:xplot,项目名称:imeet,代码行数:16,代码来源:group.py

示例2: check_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
    def check_group(self, *args, **kwargs):

        logging.info('check_group')

        if not 'groupname' in kwargs:
            logging.error('No groupname although expected')
            self.display_message('No groupname provided.')

        groupName = kwargs['groupname']
        print(groupName)
        query = Group.query(Group.name == groupName)
        groups = query.fetch()
        if len(groups) == 1:
            thisGroup = groups[0]
        else:
            thisGroup = None

        if not thisGroup:
            logging.error('Group "{groupname}" not found'.format(groupname = groupName))
            self.redirect(self.uri_for('home'), abort=True)

        self.group = thisGroup

        if handler:
            return handler(self, *args, **kwargs)

        return handler
开发者ID:fi4sk0,项目名称:supertinygroupware,代码行数:29,代码来源:main.py

示例3: post

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
    def post(self, *args, **kwargs):
        groupname = kwargs['groupname']
        query = Group.query(Group.name == groupname)
        groups = query.fetch()
        if len(groups) == 1:
            thisGroup = groups[0]
        else:
            thisGroup = None


        user = self.user

        print(user)
        if user:
            memberships = GroupMembership.query(GroupMembership.userKey == user.key,
                                                GroupMembership.groupKey == thisGroup.key).fetch()
            if len(memberships) == 1:
                membership = memberships[0]
                print(membership)
            else:
                self.display_message('You can only post if you\'re a member')

                return

        if user:
            print(self.request.get('message'))
            newMessage = Message(parent=thisGroup.key, userKey=user.key, text=self.request.get('message'))
            newMessage.put()

        self.redirect('/{groupname}/show'.format(groupname = groupname))
开发者ID:fi4sk0,项目名称:supertinygroupware,代码行数:32,代码来源:main.py

示例4: get

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
 def get(self):
   """Renders the system setup page"""
   user_id = users.get_current_user().user_id()
   #TODO: Add multiple group functionality
   group_list = Group.query(Group.owner_id == user_id).fetch(1)
   if group_list:
     self.redirect('/')
     return
   self.render_template('setupdevice.html')
开发者ID:RaspberryPiFi,项目名称:CloudCode,代码行数:11,代码来源:settings.py

示例5: post

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
 def post(self):
   """Claims the device registration number provided as the user's"""
   registration_code = self.request.get('registration_code')
   query = Group.query(Group.registration_code == registration_code)
   group_list = query.fetch(1)
   if not group_list:
     self.render_template('setupdevice.html', {'error': True})
   else:
     group = group_list[0]
     group.registered = True
     group.owner_id = users.get_current_user().user_id()
     group.put()
     self.redirect('/')
     #TODO: Redirect to page that waits about 5-10 seconds then redirects
     
     
     
开发者ID:RaspberryPiFi,项目名称:CloudCode,代码行数:16,代码来源:settings.py

示例6: get

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
 def get(self):
     user, logout = check_user(users.get_current_user())
     if user:
         u = []
         more = True
         cursor = None
         while more:
             d, curs, more = Group.query(
                 Group.active == True).order(
                     -Group.when).fetch_page(
                         10, start_cursor=cursor)
             for ditem in d:
                 u.append(ditem.to_dict())
                     
     else:
         u = []
         
     self.response.out.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps({'data':u}))
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:21,代码来源:resources.py

示例7: post

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
    def post(self):

        # logging.info("Inside the DB handler stufff now in group.")
        # solo_hacker_name = self.request.get("name")
        # solo_hacker_slackid = self.request.get("slackid")
        solo_hacker_skills = json.loads(self.request.get("skill"))
        # logging.warning(solo_hacker_skills)

        new_hacker = Hacker (
            hacker_name =  self.request.get("name"),
            slack_id =  self.request.get("slackid"),
            skills = json.loads(self.request.get("skill"))
        )
        new_hacker.put()

        groups_matching = Group.query(Group.skills_needed.IN(solo_hacker_skills))

        for matchedgroup in groups_matching :
            logging.warning(matchedgroup)
            GROUPS_ENTRIES.append({'groupname': matchedgroup.group_name,'description' : matchedgroup.description,'skills_needed' : matchedgroup.skills_needed})
开发者ID:mariemayadi,项目名称:hackmate,代码行数:22,代码来源:main.py

示例8: get

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
    def get(self):
        groupsQuery = Group.query()
        groups = groupsQuery.fetch()

        membershipQuery = GroupMembership.query(GroupMembership.userKey==self.user.key)
        memberships = membershipQuery.fetch()


        membershipStatus = []

        for group in groups:

            foundMembership = False
            for membership in memberships:
                if membership.groupKey == group.key:
                    foundMembership = True
                    break

            membershipStatus.append(foundMembership)


        params = {'groupsAndMemberships': zip(groups, membershipStatus)}

        self.render_template('listgroups.html', params=params)
开发者ID:fi4sk0,项目名称:supertinygroupware,代码行数:26,代码来源:main.py

示例9: get_groups_for_user

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import query [as 别名]
 def get_groups_for_user(self):
     return Group.query(Group.user == self.user_key).fetch()
开发者ID:xplot,项目名称:imeet,代码行数:4,代码来源:group.py


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