def index(self): """ Main web page for creating requests """ # Get the scram Architecture from the keys and the # CMSSW versions from the values self.scramArchs = SoftwareAdmin.listSoftware().keys() versionLists = SoftwareAdmin.listSoftware().values() self.versions = [] for l in versionLists: for v in l: if not v in self.versions: self.versions.append(v) self.versions.sort() # see if this was configured with a hardcoded user. If not, take from the request header requestor = self.requestor if not requestor: requestor = cherrypy.request.user["login"] if not requestor: return "No username found in your certificate" if not requestor in Registration.listUsers(): return "User %s is not registered. Contact a ReqMgr administrator." % requestor groups = GroupInfo.groupsForUser(requestor).keys() if groups == []: return "User " + requestor + " is not in any groups. Contact a ReqMgr administrator." campaigns = Campaign.listCampaigns() return self.templatepage("WebRequestSchema", yuiroot=self.yuiroot, requestor=requestor, groups=groups, versions=self.versions, archs = self.scramArchs, alldocs = Utilities.unidecode(self.allDocs()), allcampaigns = campaigns, defaultVersion=self.cmsswVersion, defaultSkimConfig=self.defaultSkimConfig)
def index(self): """ Main web page for creating requests """ # Get the scram Architecture from the keys and the # CMSSW versions from the values self.scramArchs = SoftwareAdmin.listSoftware().keys() versionLists = SoftwareAdmin.listSoftware().values() self.versions = [] for l in versionLists: for v in l: if not v in self.versions: self.versions.append(v) self.versions.sort() # see if this was configured with a hardcoded user. If not, take from the request header requestor = self.requestor if not requestor: requestor = cherrypy.request.user["login"] if not requestor: return "No username found in your certificate" if not requestor in Registration.listUsers(): return "User %s is not registered. Contact a ReqMgr administrator." % requestor groups = GroupInfo.groupsForUser(requestor).keys() if groups == []: return "User " + requestor + " is not in any groups. Contact a ReqMgr administrator." campaigns = Campaign.listCampaigns() return self.templatepage("WebRequestSchema", yuiroot=self.yuiroot, requestor=requestor, groups=groups, versions=self.versions, archs=self.scramArchs, alldocs=Utilities.unidecode(self.allDocs()), allcampaigns=campaigns, defaultVersion=self.cmsswVersion, defaultArch=self.defaultArch, defaultSkimConfig=self.defaultSkimConfig)
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)
def getGroup(self, group=None, user=None): """ No args lists all groups, one args returns JSON with users.""" if group != None: result = {} result['users'] = GroupInfo.usersInGroup(group) return result elif user != None: return GroupInfo.groupsForUser(user).keys() else: return GroupInfo.listGroups()
def user(self, userName): """ Web page of details about the user. """ self.validate(userName) groups = GroupInfo.groupsForUser(userName).keys() requests = UserRequests.listRequests(userName).keys() allGroups = GroupInfo.listGroups() self.validate(groups) self.validate(requests) self.validate(allGroups) return self.templatepage("User", user=userName, groups=groups, allGroups=allGroups, requests=requests)
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()
def user(self, userName): """ Web page of details about the user, and sets user priority """ self.validate(userName) groups = GroupInfo.groupsForUser(userName).keys() requests = UserRequests.listRequests(userName).keys() priority = UserManagement.getPriority(userName) allGroups = GroupInfo.listGroups() self.validate(groups) self.validate(requests) self.validate(allGroups) return self.templatepage("User", user=userName, groups=groups, allGroups=allGroups, requests=requests, priority=priority)
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()
def getUser(self, userName = None, group = None): """ No args returns a list of all users. Group returns groups this user is in. Username returs a JSON with information about the user """ if userName != None: if not Registration.isRegistered(userName): raise cherrypy.HTTPError(404, "Cannot find user") result = {} result['groups'] = GroupInfo.groupsForUser(userName).keys() result['requests'] = UserRequests.listRequests(userName).keys() result.update(Registration.userInfo(userName)) return result elif group != None: GroupInfo.usersInGroup(group) else: return Registration.listUsers()
def getUser(self, userName=None, group=None): """ No args returns a list of all users. Group returns groups this user is in. Username returs a JSON with information about the user """ if userName != None: if not Registration.isRegistered(userName): raise cherrypy.HTTPError(404, "Cannot find user") result = {} result['groups'] = GroupInfo.groupsForUser(userName).keys() result['requests'] = UserRequests.listRequests(userName).keys() result.update(Registration.userInfo(userName)) return result elif group != None: GroupInfo.usersInGroup(group) else: return Registration.listUsers()