當前位置: 首頁>>代碼示例>>Python>>正文


Python permission.Permission類代碼示例

本文整理匯總了Python中server.models.permission.Permission的典型用法代碼示例。如果您正苦於以下問題:Python Permission類的具體用法?Python Permission怎麽用?Python Permission使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Permission類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: groups

 def groups(self, start=None, end=None, limit=25):
     from server.models.permission import Permission
     db = core.connect()
     if not start:
         start = [self.id]
     if not end:
         end = [self.id, {}]
     results = Permission.readable_by_user_and_created(db, limit=limit)
     return Permission.joinData(core.objects(results[start:end]))
開發者ID:gmatters,項目名稱:shiftspace,代碼行數:9,代碼來源:ssuser.py

示例2: inviteUser

    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)
開發者ID:electrikfreak,項目名稱:shiftspace,代碼行數:14,代碼來源:group.py

示例3: setPrivilege

 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)
開發者ID:ShiftSpace,項目名稱:shiftspace,代碼行數:7,代碼來源:group.py

示例4: join

 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)
開發者ID:ShiftSpace,項目名稱:shiftspace,代碼行數:7,代碼來源:group.py

示例5: delete

 def delete(self):
     from server.models.permission import Permission
     server = core.sharedServer()
     # delete the metadata
     db = core.connect()
     del db[self.id]
     # delete the group database
     del server[Group.db(self.id)]
     # delete all permissions
     [perm.delete() for perm in core.objects(Permission.by_group(core.connect(), key=self.id))]
開發者ID:ShiftSpace,項目名稱:shiftspace,代碼行數:10,代碼來源:group.py

示例6: create

    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
開發者ID:electrikfreak,項目名稱:shiftspace,代碼行數:20,代碼來源:group.py

示例7: testPublishToGroup

 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()
開發者ID:xncroft,項目名稱:shiftspace,代碼行數:23,代碼來源:shift_model_test.py

示例8: testPublishToGroupAndUser

 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)
開發者ID:xncroft,項目名稱:shiftspace,代碼行數:21,代碼來源:shift_model_test.py

示例9: members

    def members(self):
        from server.models.permission import Permission

        db = core.connect()
        return core.fetch(core.connect(), keys=[row.value for row in Permission.all_members(db, key=self.id).rows])
開發者ID:electrikfreak,項目名稱:shiftspace,代碼行數:5,代碼來源:group.py

示例10: adminable

 def adminable(self):
     from server.models.permission import Permission
     return Permission.adminable(self.id)
開發者ID:gmatters,項目名稱:shiftspace,代碼行數:3,代碼來源:ssuser.py

示例11: writeable

 def writeable(self):
     from server.models.permission import Permission
     return Permission.writeable(self.id)
開發者ID:gmatters,項目名稱:shiftspace,代碼行數:3,代碼來源:ssuser.py

示例12: readable

 def readable(self):
     from server.models.permission import Permission
     return Permission.readable(self.id)
開發者ID:gmatters,項目名稱:shiftspace,代碼行數:3,代碼來源:ssuser.py

示例13: isMemberOf

 def isMemberOf(self, aGroup):
     from server.models.permission import Permission
     thePermission = Permission.readByUserAndGroup(self.id, aGroup.id)
     return thePermission and Permission.level > 0
開發者ID:gmatters,項目名稱:shiftspace,代碼行數:4,代碼來源:ssuser.py

示例14: canJoin

 def canJoin(self, group):
     from server.models.permission import Permission
     perm = Permission.readByUserAndGroup(self.id, group.id)
     return (perm and perm.level == 0)
開發者ID:gmatters,項目名稱:shiftspace,代碼行數:4,代碼來源:ssuser.py

示例15: adminCount

    def adminCount(self):
        from server.models.permission import Permission

        db = core.connect()
        return core.value(Permission.admin_count(db, key=self.id))
開發者ID:electrikfreak,項目名稱:shiftspace,代碼行數:5,代碼來源:group.py


注:本文中的server.models.permission.Permission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。