本文整理汇总了Python中server.models.permission.Permission.create方法的典型用法代码示例。如果您正苦于以下问题:Python Permission.create方法的具体用法?Python Permission.create怎么用?Python Permission.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.models.permission.Permission
的用法示例。
在下文中一共展示了Permission.create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: inviteUser
# 需要导入模块: from server.models.permission import Permission [as 别名]
# 或者: from server.models.permission.Permission import create [as 别名]
def inviteUser(self, aUser, otherUser):
from server.models.permission import Permission
from server.models.message import Message
Permission.create(aUser.id, self.id, otherUser.id, 0)
json = {
"fromId": aUser.id,
"toId": otherUser.id,
"title": "%s invited you to join the group %s!" % (aUser.userName, self.longName),
"text": "%s invited you to join the group %s!" % (aUser.userName, self.longName),
"meta": "invite",
"content": {"type": "group", "_id": self.id},
}
Message.create(**json)
示例2: create
# 需要导入模块: from server.models.permission import Permission [as 别名]
# 或者: from server.models.permission.Permission import create [as 别名]
def create(cls, groupJson):
from server.models.permission import Permission
from server.models.ssuser import SSUser
userId = groupJson["createdBy"]
# create the group metadata
newGroup = Group(**utils.clean(groupJson))
newGroup.source.server = core.serverName()
newGroup.source.database = Group.db(newGroup.id)
# save the group metadata to the master db
newGroup.store(core.connect())
# create the root permission for this group
Permission.create(userId, newGroup.id, userId, level=4)
# create the group db
server = core.sharedServer()
server.create(Group.db(newGroup.id))
# copy the group metadata to the db
newGroup.copyTo(Group.db(newGroup.id))
return newGroup
示例3: testPublishToGroupAndUser
# 需要导入模块: from server.models.permission import Permission [as 别名]
# 或者: from server.models.permission.Permission import create [as 别名]
def testPublishToGroupAndUser(self):
json = shiftJson()
json["createdBy"] = self.fakemary.id
newShift = Shift.create(json)
json = groupJson()
json["createdBy"] = self.fakemary.id
newGroup = Group.create(json)
newPerm = Permission.create("shiftspace", newGroup.id, self.fakejohn.id, level=1)
publishData = {
"dbs": [Group.db(newGroup.id), SSUser.db(self.fakebob.id)]
}
newShift.publish(publishData)
# should exist in subscriber's feed
db = core.connect("shiftspace/shared")
theShift = Shift.load(db, newShift.id)
self.assertEqual(theShift.summary, newShift.summary)
newGroup.delete()
# should exist in shiftspace/shared
# TODO: inbox if user is peer - David 11/18/09
theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
self.assertEqual(theShift.summary, newShift.summary)
示例4: testPublishToGroup
# 需要导入模块: from server.models.permission import Permission [as 别名]
# 或者: from server.models.permission.Permission import create [as 别名]
def testPublishToGroup(self):
json = shiftJson()
json["createdBy"] = self.fakemary.id
newShift = Shift.create(json)
json = groupJson()
json["createdBy"] = self.fakemary.id
newGroup = Group.create(json)
# make sure fakemary owns the group
newPerm = Permission.readByUserAndGroup(self.fakemary.id, newGroup.id)
self.assertTrue(newPerm.level == 4)
# create read permission for fakejohn
newPerm = Permission.create("shiftspace", newGroup.id, self.fakejohn.id, level=1)
fakejohn = SSUser.read(self.fakejohn.id)
self.assertTrue(Group.db(newGroup.id) in fakejohn.readable())
publishData = {
"dbs": [Group.db(newGroup.id)]
}
newShift.publish(publishData)
# should exists in shiftspace/shared
db = core.connect("shiftspace/shared")
theShift = Shift.load(db, newShift.id)
self.assertEqual(theShift.summary, newShift.summary)
newGroup.delete()