本文整理汇总了Python中server.models.ssuser.SSUser类的典型用法代码示例。如果您正苦于以下问题:Python SSUser类的具体用法?Python SSUser怎么用?Python SSUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SSUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: read
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,代码行数:7,代码来源:user.py
示例2: update
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,代码行数:30,代码来源:shift.py
示例3: publish
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,代码行数:30,代码来源:shift.py
示例4: unfollow
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,代码行数:8,代码来源:user.py
示例5: unreadCount
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,代码行数:8,代码来源:user.py
示例6: groups
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,代码行数:8,代码来源:user.py
示例7: create
def create(cls, shiftJson):
from server.models.ssuser import SSUser
newShift = Shift(**utils.clean(shiftJson))
createdBy = newShift.createdBy
db = core.connect(SSUser.privateDb(createdBy))
newShift.domain = utils.domain(newShift.href)
newShift.store(db)
core.replicate(SSUser.privateDb(createdBy), "shiftspace/shared")
return Shift.joinData(newShift, newShift.createdBy)
开发者ID:gmatters,项目名称:shiftspace,代码行数:9,代码来源:shift.py
示例8: update
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,代码行数:10,代码来源:user.py
示例9: makeAdmin
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,代码行数:10,代码来源:group.py
示例10: delete
def delete(self):
from server.models.ssuser import SSUser
db = core.connect(SSUser.privateDb(self.createdBy))
if db.get(self.id):
del db[self.id]
else:
db = core.connect(SSUser.publicDb(self.createdBy))
if db.get(self.id):
del db[self.id]
core.replicate(db.name, "shiftspace/shared")
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:10,代码来源:shift.py
示例11: create
def create(cls, userId, shiftId, text, subscribe=False):
from server.models.ssuser import SSUser
from server.models.shift import Shift
from server.models.message import Message
# first try the public feed
theShift = Shift.load(core.connect("shiftspace/shared"), shiftId)
shiftAuthor = SSUser.load(core.connect(), theShift.createdBy)
theUser = SSUser.load(core.connect(), userId)
server = core.server()
# create the comment db if necessary
dbexists = True
if not theShift.hasThread():
server.create(Comment.db(shiftId))
dbexists = False
# get the db
db = core.connect(Comment.db(shiftId))
# if db just created, sync the views and subscribe shift author
if not dbexists:
Comment.by_created.sync(db)
Comment.all_subscribed.sync(db)
shiftAuthor.subscribe(theShift)
# subscribe the user making the comment
if not theUser.isSubscribed(theShift) and subscribe:
theUser.subscribe(theShift)
# create comment and comment stub
json = {
"createdBy": userId,
"shiftId": shiftId,
"shiftAuthor": theShift.createdBy,
"text": text,
}
newComment = Comment(**utils.clean(json))
newComment.store(db)
subscribers = theShift.subscribers()
# make a private copy
# TODO: need to think about the implications of a private copy here - David
newComment.copyTo(SSUser.privateDb(theUser.id))
# send each subscriber a message
if len(subscribers) > 0:
# TODO: needs to be optimized with a fast join - David
for subscriber in subscribers:
if subscriber != userId:
astr = ((subscriber == theShift.createdBy) and "your") or ("%s's" % shiftAuthor.userName)
json = {
"fromId": userId,
"toId": subscriber,
"title": "%s just commented on %s shift!" % (theUser.userName, astr),
"text": "%s just commented on %s shift!" % (theUser.userName, astr),
"meta": "comment"
}
Message.create(**utils.clean(json))
# TODO: don't replicate if peer - David 11/21/09
core.replicate(Comment.db(shiftId), "shiftspace/shared")
return newComment
开发者ID:gmatters,项目名称:shiftspace,代码行数:54,代码来源:comment.py
示例12: share
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,代码行数:11,代码来源:shift.py
示例13: delete
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,代码行数:12,代码来源:user.py
示例14: inviteUsers
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,代码行数:13,代码来源:group.py
示例15: markRead
def markRead(self, value=True):
from server.models.ssuser import SSUser
db = core.connect(SSUser.messagesDb(self.toId))
if value:
if not self.isRead():
db[Message.makeReadId(self.id, self.toId)] = {
"type": "message-read",
"msgId": self.id,
"toId": self.toId,
}
else:
del db[Message.makeReadId(self.id, self.toId)]
core.replicate(SSUser.messagesDb(self.toId), "shiftspace/shared")
return self
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:14,代码来源:message.py
示例16: shifts
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)
开发者ID:gmatters,项目名称:shiftspace,代码行数:14,代码来源:user.py
示例17: read
def read(cls, id, userId=None):
from server.models.ssuser import SSUser
if userId != None:
# then try the user public
db = core.connect(SSUser.publicDb(userId))
theShift = Shift.load(db, id)
if not theShift:
# then user private
db = core.connect(SSUser.privateDb(userId))
theShift = Shift.load(db, id)
else:
theShift = Shift.load(core.connect("shiftspace/shared"), id)
if theShift:
return Shift.joinData(theShift, theShift.createdBy)
开发者ID:gmatters,项目名称:shiftspace,代码行数:14,代码来源:shift.py
示例18: create
def create(cls, fromId, toId, title, text, meta="generic", content=None):
from server.models.ssuser import SSUser
db = core.connect(SSUser.messagesDb(toId))
json = {
"fromId": fromId,
"toId": toId,
"title": text,
"text": text,
"meta": meta,
"content": content or {}
}
newMessage = Message(**utils.clean(json))
newMessage.store(db)
core.replicate(SSUser.messagesDb(toId), "shiftspace/shared")
return newMessage
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:15,代码来源:message.py
示例19: read
def read(cls, id, userId=None):
db = core.connect("shiftspace/shared")
theMessage = Message.load(db, id)
if theMessage == None and userId:
db = core.connect(SSUser.messagesDb(userId))
theMessage = Message.load(db, id)
return Message.joinData(theMessage, userId)
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:7,代码来源:message.py
示例20: create
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,代码行数:33,代码来源:permission.py
注:本文中的server.models.ssuser.SSUser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论