本文整理匯總了Python中server.models.permission.Permission.readByUserAndGroup方法的典型用法代碼示例。如果您正苦於以下問題:Python Permission.readByUserAndGroup方法的具體用法?Python Permission.readByUserAndGroup怎麽用?Python Permission.readByUserAndGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類server.models.permission.Permission
的用法示例。
在下文中一共展示了Permission.readByUserAndGroup方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setPrivilege
# 需要導入模塊: from server.models.permission import Permission [as 別名]
# 或者: from server.models.permission.Permission import readByUserAndGroup [as 別名]
def setPrivilege(self, aUser, level):
from server.models.permission import Permission
thePermission = Permission.readByUserAndGroup(aUser.id, self.id)
if thePermission and level > 0:
db = core.connect()
thePermission.level = level
thePermission.store(db)
示例2: join
# 需要導入模塊: from server.models.permission import Permission [as 別名]
# 或者: from server.models.permission.Permission import readByUserAndGroup [as 別名]
def join(self, aUser):
from server.models.permission import Permission
thePermission = Permission.readByUserAndGroup(aUser.id, self.id)
if thePermission and thePermission.level == 0:
db = core.connect()
thePermission.level = 2
thePermission.store(db)
示例3: testPublishToGroup
# 需要導入模塊: from server.models.permission import Permission [as 別名]
# 或者: from server.models.permission.Permission import readByUserAndGroup [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()
示例4: isMemberOf
# 需要導入模塊: from server.models.permission import Permission [as 別名]
# 或者: from server.models.permission.Permission import readByUserAndGroup [as 別名]
def isMemberOf(self, aGroup):
from server.models.permission import Permission
thePermission = Permission.readByUserAndGroup(self.id, aGroup.id)
return thePermission and Permission.level > 0
示例5: canJoin
# 需要導入模塊: from server.models.permission import Permission [as 別名]
# 或者: from server.models.permission.Permission import readByUserAndGroup [as 別名]
def canJoin(self, group):
from server.models.permission import Permission
perm = Permission.readByUserAndGroup(self.id, group.id)
return (perm and perm.level == 0)
示例6: setPrivilege
# 需要導入模塊: from server.models.permission import Permission [as 別名]
# 或者: from server.models.permission.Permission import readByUserAndGroup [as 別名]
def setPrivilege(self, aUser, level):
thePermission = Permission.readByUserAndGroup(aUser.id, self.id)
if thePermission and level > 0:
db = core.connect()
thePermission.level = level
thePermission.store(db)