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


Python Group.read方法代码示例

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


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

示例1: update

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
    def update(self, fields, updateDbs=True):
        from server.models.ssuser import SSUser
        if fields.get("content"):
            self.content = fields.get("content")
        if fields.get("summary"):
            self.summary = self.content["summary"] = fields.get("summary")
        if fields.get("broken"):
            self.broken = fields.get("broken")
        if fields.get("dbs"):
            self.dbs = list(set(self.dbs.extend(fields.get("dbs"))))
        self.modified = datetime.now()
        
        # update the correct user db
        if self.publishData.private:
            db = SSUser.privateDb(self.createdBy)
        else:
            db = SSUser.publicDb(self.createdBy)
        
        self.store(core.connect(db))
        core.replicate(db, "shiftspace/shared")
        
        # update followers and groups
        if updateDbs:
            for db in self.publishData.dbs:
                dbtype, dbid = db.split("/")
                if dbtype == "group":
                    from server.models.group import Group
                    Group.read(dbid).updateShift(self)

        return Shift.joinData(self, self.createdBy)
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:32,代码来源:shift.py

示例2: create

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
    def create(cls, userId, groupId, otherId, level):
        from server.models.ssuser import SSUser
        from server.models.group import Group

        db = core.connect()
        if not groupId:
            raise MissingGroupError
        if not userId:
            raise MissingCreatorError
        if Permission.readByUserAndGroup(otherId, groupId):
            raise PermissionAlreadyExistsError

        adminable = [row.value for row in Permission.by_adminable(db, key=userId).rows]
        allowed = groupId in adminable
        if not allowed:
            theUser = SSUser.read(userId)
            allowed = theUser.isAdmin()
        if not allowed:
            theGroup = Group.read(groupId)
            allowed = theUser.isOwnerOf(theGroup)
        if not allowed:
            raise CreateEventPermissionError

        json = {
            "createdBy": userId,
            "userId": otherId,
            "groupId": groupId,
            "level": level
            }

        newPermission = Permission(**utils.clean(json))
        newPermission.store(db)
        return newPermission
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:35,代码来源:permission.py

示例3: addToGroups

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def addToGroups(self, groupDbs):
     from server.models.group import Group
     # NOTE - do we need to delete from user/private? - David 11/12/09
     for db in groupDbs:
         dbtype, dbid = db.split("/")
         theGroup = Group.read(dbid)
         theGroup.addShift(self)
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:9,代码来源:shift.py

示例4: members

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def members(self, id):
     from server.models.ssuser import SSUser
     theGroup = Group.read(id)
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     if theUser.isAdminOf(theGroup):
         return data(theGroup.members())
     else:
         return error("You don't have permission to view this groups members", PermissionError)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:11,代码来源:group.py

示例5: join

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def join(self, id):
     from server.models.ssuser import SSUser
     theGroup = Group.read(id)
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     if theUser.canJoin(theGroup):
         theUser.join(theGroup)
         return data(theGroup)
     else:
         return error("Operation not permitted. You don't have permission to join this group.", PermissionError)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:12,代码来源:group.py

示例6: makeAdmin

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def makeAdmin(self, id, userId):
     from server.models.ssuser import SSUser
     theGroup = Group.read(id)
     theUser = SSUser.read(helper.getLoggedInUser())
     if theUser.isAdminOf(theGroup):
         otherUser = SSUser.read(userId)
         theGroup.setPrivilege(otherUser, 3)
         return ack
     else:
         return error("You don't have permission to promote members of this group to admin.", PermissionError)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:12,代码来源:group.py

示例7: inviteUsers

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def inviteUsers(self, id, users):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     groupAdmin = SSUser.read(loggedInUser)
     theGroup = Group.read(id)
     if groupAdmin.isAdminOf(theGroup):
         db = core.connect()
         users = SSUser.all(db, keys=json.loads(users))
         for user in users:
             groupAdmin.inviteUser(theGroup, user)
         return data(theGroup)
     else:
         return error("Operation not permitted. You don't have permission to modify this group", PermissionError)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:15,代码来源:group.py

示例8: update

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def update(self, id):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     theGroup = Group.read(id)
     jsonData = helper.getRequestBody()
     if jsonData != "":
         if theUser.isAdminOf(theGroup):
             groupData = json.loads(jsonData)
             return data(theGroup.update(groupData))
         else:
             return error("You don't have permission to update this group", PermissionError)
     else:
         return error("No data for group.", NoDataError)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:16,代码来源:group.py

示例9: info

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def info(self, id):
     from server.models.ssuser import SSUser
     # TODO: bulk call - David 12/13/2009
     theGroup = Group.read(id)
     memberCount = theGroup.memberCount()
     adminCount = theGroup.adminCount()
     shiftCount = theGroup.shiftCount()
     info = {
         "memberCount": memberCount,
         "adminCount": adminCount,
         "shiftCount": shiftCount
         }
     theUser = SSUser.read(helper.getLoggedInUser())
     info["isAdmin"] = theUser.isAdminOf(theGroup)
     return data(info)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:17,代码来源:group.py

示例10: updateInGroups

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def updateInGroups(self, groupDbs):
     from server.models.group import Group
     for db in groupDbs:
         dbtype, dbid = db.split("/")
         theGroup = Group.read(dbid)
         theGroup.updateShift(self)
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:8,代码来源:shift.py

示例11: read

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
 def read(self, id):
     # return only public groups
     theGroup = Group.read(id)
     return data(theGroup)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:6,代码来源:group.py


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