Пример #1
0
 def setPermission(self, id, userName, level):
     loggedInUser = helper.getLoggedInUser()
     if stream.canAdmin(id, loggedInUser["_id"]):
         permission.updateForUser(user.idForName(userName), id, level)
         return ack
     else:
         return error("Operation not permitted. You don't have permission to view permssions on this stream.", PermissionError)
Пример #2
0
 def add(self, id, userName):
     loggedInUser = helper.getLoggedInUser()
     if stream.canAdmin(id, loggedInUser["_id"]):
         otherId = user.idForName(userName)
         if user.isSubscribed(otherId, id):
             return error("User %s is already subscribed to that stream." % userName, AlreadySubscribedError)
         else:
             stream.invite(id, loggedInUser["_id"], otherId)
             return ack
     else:
         return error("Operation not permitted. You don't have permission to subscribe to this stream.", PermissionError)
Пример #3
0
 def create(self):
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theData = json.loads(jsonData)
         streamId = theData["streamId"]
         if not streamId:
             return error("You did not specify a stream to create a permission for", CreatePermissionError)
         if stream.canAdmin(streamId, loggedInUser["_id"]):
             return data(permission.create(theData))
     else:
         return error("No data for permission.", NoDataError)
Пример #4
0
 def permissions(self, id):
     loggedInUser = helper.getLoggedInUser()
     if stream.canAdmin(id, loggedInUser["_id"]):
         return data(permission.permissionsForStream(id))
     else:
         return error("Operation not permitted. You don't have permission to view permssions on this stream.", PermissionError)