本文整理汇总了Python中server.models.ssuser.SSUser.readByName方法的典型用法代码示例。如果您正苦于以下问题:Python SSUser.readByName方法的具体用法?Python SSUser.readByName怎么用?Python SSUser.readByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.models.ssuser.SSUser
的用法示例。
在下文中一共展示了SSUser.readByName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [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)))
示例2: groups
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [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)
示例3: unreadCount
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [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)
示例4: unfollow
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [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)
示例5: update
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [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.")
示例6: delete
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [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.")
示例7: shifts
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [as 别名]
def shifts(self, userName, start=None, end=None, limit=25, filter=False, query=None):
loggedInUser = helper.getLoggedInUser()
theUser = SSUser.read(loggedInUser)
otherUser = SSUser.readByName(userName)
if query != None:
query = json.loads(query)
if loggedInUser == otherUser.id or theUser.isAdmin():
return data(otherUser.shifts(start=start,
end=end,
limit=limit,
filter=filter,
query=query))
else:
return error("You don't have permission to view this user's shifts.", PermissionError)
示例8: login
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [as 别名]
def login(self, userName, password):
loggedInUser = helper.getLoggedInUser()
if not loggedInUser:
theUser = SSUser.readByName(userName)
if not theUser:
return error("Invalid user name.", InvalidUserNameError)
if theUser and (theUser.password == md5hash(password)):
helper.setLoggedInUser(theUser.id)
# TODO: perhaps don't update yet, might want to use for unread counts - David
theUser.updateLastSeen()
return data(theUser)
else:
return error("Incorrect password.", IncorrectPasswordError)
else:
return error("Already logged in.", AlreadyLoggedInError)
示例9: resolveResource
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [as 别名]
def resolveResource(self, userName):
theUser = SSUser.readByName(userName)
return (theUser and theUser.id)
示例10: info
# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import readByName [as 别名]
def info(self, userName):
theUser = SSUser.readByName(userName)
return data(theUser.info())