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


Python SSUser.read方法代码示例

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


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

示例1: makeAdmin

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser 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

示例2: publish

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def publish(self, id):
     # NOTE: should maybe take publishData url parameter - David 9/5/2009
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id, loggedInUser)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     publishData = json.loads(helper.getRequestBody())
     # convert targets to actual database references
     if publishData.get("targets"):
         from server.models.group import Group
         from server.models.ssuser import SSUser
         theUser = SSUser.read(loggedInUser)
         targets = publishData["targets"]
         # convert short names to group ids
         shortNames = [target[1:] for target in targets if target[0] == "&"]
         groupIds = Group.shortNamesToIds(shortNames)
         # convert user name to user ids
         userNames = [target[1:] for target in targets if target[0] == "@"]
         userIds = SSUser.namesToIds(userNames)
         # create list of dbs being published to
         dbs = [Group.db(groupId) for groupId in groupIds]
         dbs.extend([SSUser.db(userId) for userId in userIds])
         # validate
         writeable = theUser.writeable()
         if set(writeable) != set(dbs):
             return error("Operation not permitted. You don't have permission to publish to some of these gruops", PermissionError)
         publishData["dbs"] = dbs
     return data(theShift.publish(publishData))
开发者ID:gmatters,项目名称:shiftspace,代码行数:32,代码来源:shift.py

示例3: read

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def read(self, userName):
     theUser = SSUser.readByName(userName)
     if not theUser:
         return error("User %s does not exist" % userName, UserDoesNotExistError)
     loggedInUser = SSUser.read(helper.getLoggedInUser())
     canReadFull = loggedInUser.canReadFull(theUser)
     return data(theUser.toDict((loggedInUser and canReadFull)))
开发者ID:gmatters,项目名称:shiftspace,代码行数:9,代码来源:user.py

示例4: create

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser 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

示例5: unreadCount

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def unreadCount(self, userName):
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     otherUser = SSUser.readByName(userName)
     if loggedInUser == otherUser.id or theUser.isAdmin():
         return data(theUser.unreadCount())
     else:
         return error("You do not have permission to view this user's unread count.", PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:10,代码来源:user.py

示例6: groups

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def groups(self, userName, start=None, end=None, limit=25):
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     otherUser = SSUser.readByName(userName)
     if loggedInUser == otherUser.id or theUser.isAdmin():
         return data(otherUser.groups(start=start, end=end, limit=limit))
     else:
         return error("You don't have permission to view this user's groups.", PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:10,代码来源:user.py

示例7: unfollow

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def unfollow(self, userName):
     theUser = SSUser.read(helper.getLoggedInUser())
     followed = SSUser.readByName(userName)
     if theUser.id == followed.id:
         return error("You cannot unfollow yourself.", FollowError)
     else:
         theUser.unfollow(followed)
         return data(followed)
开发者ID:gmatters,项目名称:shiftspace,代码行数:10,代码来源:user.py

示例8: members

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser 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

示例9: updateShift

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def updateShift(self, aShift):
     from server.models.ssuser import SSUser
     author = SSUser.read(aShift.createdBy)
     if author.isMemberOf(self):
         grpdb = Group.db(self.id)
         aShift.updateIn(grpdb)
     else:
         db = core.connect()
         raise NotAMemberError("%s is not a member of %s" % (author.userName, self.longName))
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:11,代码来源:group.py

示例10: logout

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def logout(self):
     loggedInUser = helper.getLoggedInUser()
     if loggedInUser:
         theUser = SSUser.read(loggedInUser)
         theUser.updateLastSeen()
         helper.setLoggedInUser(None)
         return ack
     else:
         return error("No user logged in.", AlreadyLoggedOutError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:11,代码来源:user.py

示例11: join

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser 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

示例12: update

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def update(self, userName):
     theUser = SSUser.readByName(userName)
     if not theUser:
         return error("User %s does not exist" % userName, UserDoesNotExistError)
     loggedInUser = SSUser.read(helper.getLoggedInUser())
     if loggedInUser and loggedInUser.canModify(theUser):
         theData = json.loads(helper.getRequestBody())
         return data(theUser.update(theData))
     else:
         return error("Operation not permitted. You don't have permission to update this account.")
开发者ID:gmatters,项目名称:shiftspace,代码行数:12,代码来源:user.py

示例13: share

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def share(self, id, users):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id)
     if not theShift or theShift.publishData.private:
         return error("You don't have permission to view this shift.", PermissionError)
     targets = users.split(" ")
     userNames = [target[1:] for target in targets if target[0] == "@"]
     userIds = SSUser.namesToIds(userNames)
     theShift.shareWith(userIds, fromUser=SSUser.read(loggedInUser))
     return ack
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:13,代码来源:shift.py

示例14: delete

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def delete(self, userName):
     theUser = SSUser.readByName(userName)
     if not theUser:
         return error("User %s does not exist" % userName, UserDoesNotExistError)
     loggedInUser = SSUser.read(helper.getLoggedInUser())
     if loggedInUser and loggedInUser.canModify(theUser):
         if theUser.id == loggedInUser.id:
             helper.setLoggedInUser(None)
         theUser.delete()
         return ack
     else:
         return error("Operation not permitted. You don't have permission to delete this account.")
开发者ID:gmatters,项目名称:shiftspace,代码行数:14,代码来源:user.py

示例15: read

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import read [as 别名]
 def read(self, id):
     from server.models.ssuser import SSUser
     loggedInUser = helper.getLoggedInUser()
     theUser = SSUser.read(loggedInUser)
     theShift = Shift.read(id, loggedInUser)
     if theShift and theUser.canRead(theShift):
         return data(theShift)
     else:
         if not theShift:
             return error("Resource does not exist.", ResourceDoesNotExistError)
         else:
             return error("Operation not permitted. You don't have permission to view this shift. %s" % theShift, PermissionError)
开发者ID:gmatters,项目名称:shiftspace,代码行数:14,代码来源:shift.py


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