Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
 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()
Beispiel #4
0
 def isMemberOf(self, aGroup):
     from server.models.permission import Permission
     thePermission = Permission.readByUserAndGroup(self.id, aGroup.id)
     return thePermission and Permission.level > 0
Beispiel #5
0
 def canJoin(self, group):
     from server.models.permission import Permission
     perm = Permission.readByUserAndGroup(self.id, group.id)
     return (perm and perm.level == 0)
Beispiel #6
0
 def isMemberOf(self, aGroup):
     from server.models.permission import Permission
     thePermission = Permission.readByUserAndGroup(self.id, aGroup.id)
     return thePermission and Permission.level > 0
Beispiel #7
0
 def canJoin(self, group):
     from server.models.permission import Permission
     perm = Permission.readByUserAndGroup(self.id, group.id)
     return (perm and perm.level == 0)
Beispiel #8
0
 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)