本文整理汇总了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)
示例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))
示例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)))
示例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
示例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)
示例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)
示例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)
示例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)
示例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))
示例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)
示例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)
示例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.")
示例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
示例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.")
示例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)