Beispiel #1
0
 def putGroup(self, group, user=None):
     """ Creates a group, or if a user is passed, adds that user to the group """
     if (user != None):
         # assume group exists and add user to it
         return GroupManagement.addUserToGroup(user, group)
     if GroupInfo.groupExists(group):
         return "Group already exists"
     GroupManagement.addGroup(group)
Beispiel #2
0
 def putGroup(self, group, user=None):
     """ Creates a group, or if a user is passed, adds that user to the group """
     if(user != None):
         # assume group exists and add user to it
         return GroupManagement.addUserToGroup(user, group)
     if GroupInfo.groupExists(group):
         return "Group already exists"
     GroupManagement.addGroup(group)
Beispiel #3
0
 def deleteUser(self, user):
     """ Deletes a user, as well as deleting his requests and removing
         him from all groups """
     if user in self.getUser():
         requests = json.loads(self.getUser(user))['requests']
         for request in requests:
             self.deleteRequest(request)
         for group in GroupInfo.groupsForUser(user).keys():
             GroupManagement.removeUserFromGroup(user, group)
         return UserManagement.deleteUser(user)
Beispiel #4
0
 def deleteUser(self, user):
     """ Deletes a user, as well as deleting his requests and removing
         him from all groups """
     if user in self.getUser():
         requests = json.loads(self.getUser(user))['requests']
         for request in requests:
             self.deleteRequest(request)
         for group in GroupInfo.groupsForUser(user).keys():
             GroupManagement.removeUserFromGroup(user, group)
         return UserManagement.deleteUser(user)
Beispiel #5
0
 def group(self, groupName):
     """ Web page of details about the user, and sets user priority """
     self.validate(groupName)
     users = GroupInfo.usersInGroup(groupName)
     priority = GroupManagement.getPriority(groupName)
     return self.templatepage("Group",
                              group=groupName,
                              users=users,
                              priority=priority)
Beispiel #6
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users and priority """
     if group != None:
         result = {}
         result['users'] =  GroupInfo.usersInGroup(group)
         result['priority'] = GroupManagement.getPriority(group)
         return json.dumps(result)
     elif user != None:   
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
Beispiel #7
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users and priority """
     if group != None:
         result = {}
         result['users'] =  GroupInfo.usersInGroup(group)
         try:
             result['priority'] = GroupManagement.getPriority(group)
         except IndexError:
             raise cherrypy.HTTPError(404, "Cannot find group/group priority")
         return result
     elif user != None:
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
Beispiel #8
0
 def getGroup(self, group=None, user=None):
     """ No args lists all groups, one args returns JSON with users and priority """
     if group != None:
         result = {}
         result['users'] = GroupInfo.usersInGroup(group)
         try:
             result['priority'] = GroupManagement.getPriority(group)
         except IndexError:
             raise cherrypy.HTTPError(404,
                                      "Cannot find group/group priority")
         return result
     elif user != None:
         return GroupInfo.groupsForUser(user).keys()
     else:
         return GroupInfo.listGroups()
Beispiel #9
0
 def postGroup(self, group, priority):
     """ Change the group's priority """
     return GroupManagement.setPriority(group, priority)
Beispiel #10
0
 def handleAddToGroup(self, user, group):
     """ Adds a user to the group """
     self.validate(user)
     self.validate(group)
     GroupManagement.addUserToGroup(user, group)
     return "Added %s to %s " % (user, group)
Beispiel #11
0
 def handleAddGroup(self, group):
     """ Handles adding a group """
     self.validate(group)
     GroupManagement.addGroup(group)
     return "Added group %s " % group
Beispiel #12
0
 def handleGroupPriority(self, group, groupPriority):
     """ Handles setting group priority """
     self.validate(group)
     GroupManagement.setPriority(group, groupPriority)
     return "Updated group %s priority to %s" % (group, groupPriority)
Beispiel #13
0
 def handleGroupPriority(self, group, groupPriority):
     """ Handles setting group priority """
     self.validate(group)
     GroupManagement.setPriority(group, groupPriority)
     return "Updated group %s priority to %s" % (group, groupPriority)
Beispiel #14
0
 def deleteGroup(self, group, user=None):
     """ If no user is sent, delete the group.  Otherwise, delete the user from the group """
     if user == None:
         return GroupManagement.deleteGroup(group)
     else:
         return GroupManagement.removeUserFromGroup(user, group)
Beispiel #15
0
 def postGroup(self, group, priority):
     """ Change the group's priority """
     return GroupManagement.setPriority(group, priority)
Beispiel #16
0
 def deleteGroup(self, group, user=None):
     """ If no user is sent, delete the group.  Otherwise, delete the user from the group """
     if user == None:
         return GroupManagement.deleteGroup(group)
     else:
         return GroupManagement.removeUserFromGroup(user, group)
Beispiel #17
0
 def group(self, groupName):
     """ Web page of details about the user, and sets user priority """
     self.validate(groupName)
     users = GroupInfo.usersInGroup(groupName)
     priority = GroupManagement.getPriority(groupName)
     return self.templatepage("Group", group=groupName, users=users, priority=priority)