def ok(self): self.validatePasswordMatch(self.passwordEntry.get(), self.reEnterPasswordEntry.get()) user = ScrumblesObjects.User() user.userName = self.userNameEntry.get() user.userPassword = self.passwordEntry.get() user.userEmailAddress = self.emailEntry.get() user.userRole = self.roleCombobox.get() self.validateName(user.userName) try: if not self.isTest: self.dataBlock.addNewScrumblesObject(user) except IntegrityError: logging.exception('ID Collision') user.userID = ScrumblesObjects.generateRowID() self.dataBlock.addNewScrumblesObject(user) else: messagebox.showinfo('Info', 'New User Successfully Created') self.exit()
def updateAllObjects(self): if self.firstLoad: time.sleep(1) self.isLoading = True funcStartTime = time.clock() self.conn.connect() self.users.clear() self.items.clear() self.projects.clear() self.comments.clear() self.tags.clear() self.sprints.clear() self.itemMap = {} self.sprintMap = {} self.commentMap = {} self.projectMap = {} self.userMap = {} #print('getting tables') loopStartTime = time.clock() userTable = self.conn.getData(Query.getAllUsers) itemTable = self.conn.getData(Query.getAllCards) projectTable = self.conn.getData(Query.getAllProjects) commentTable = self.conn.getData(Query.getAllComments) sprintTable = self.conn.getData(Query.getAllSprints) userToProjectRelationTable = self.conn.getData(Query.getAllUserProject) itemToProjectRelationTable = self.conn.getData(Query.getAllProjectItem) itemTimeLineTable = self.conn.getData('SELECT * FROM CardTimeLine') epicTable = self.conn.getData('SELECT * FROM EpicTable') self.conn.close() #print('Tables loaded in %fms' % ((time.clock()-loopStartTime)*1000) ) loopStartTime = time.clock() #print('splicing vectors') timeLineMap = self.mapTimeline(itemTimeLineTable) epicMap = self.buildEpicMap(epicTable) for comment in commentTable: Comment = ScrumblesObjects.Comment(comment) self.comments.append(Comment) self.commentMap[Comment.commentID] = Comment #print('Comment List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for item in itemTable: Item = ScrumblesObjects.Item(item) Item.listOfComments = [ C for C in self.comments if C.commentItemID == Item.itemID ] self.applyItemLine(Item, timeLineMap) # try: # Item.itemTimeLine = timeLineMap[Item.itemID] # except KeyError: # timeLineMap = self.reloadTimeLineMap() if 'AssignedToSPrint' in Item.itemTimeLine: Item.itemTimeLine['AssignedToSprint'] = Item.itemTimeLine[ 'AssignedToSPrint'] #self.populateItemTimeLine(Item,timeLineMap) self.itemMap[Item.itemID] = Item self.items.append(Item) #print('Item List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for I in self.items: if I.itemID in epicMap: #epicMap[subitemID]->EpicID self.itemMap[epicMap[I.itemID]].subItemList.append( I) #itemMap[itemID]->Item #print('Item subitems spliced in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for user in userTable: User = ScrumblesObjects.User(user) User.listOfAssignedItems = [ I for I in self.items if I.itemUserID == User.userID ] User.listOfComments = [ C for C in self.comments if C.commentUserID == User.userID ] self.users.append(User) self.userMap[User.userID] = User #print('User List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for sprint in sprintTable: Sprint = ScrumblesObjects.Sprint(sprint) Sprint.listOfAssignedItems = [ I for I in self.items if I.itemSprintID == Sprint.sprintID ] Sprint.listOfAssignedUsers = [ U for U in self.users if U.userID in [I.itemUserID for I in Sprint.listOfAssignedItems] ] self.sprints.append(Sprint) self.sprintMap[Sprint.sprintID] = Sprint #print('Sprint List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for project in projectTable: Project = ScrumblesObjects.Project(project) Project.listOfAssignedSprints = [ S for S in self.sprints if S.projectID == Project.projectID ] self.projects.append(Project) self.projectMap[Project.projectID] = Project #print('Project List Built in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for user in self.users: for dict in userToProjectRelationTable: if dict['UserID'] == user.userID: for project in self.projects: if dict['ProjectID'] == project.projectID: user.listOfProjects.append(project) #print('Users Spliced to Projects in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for project in self.projects: for dict in userToProjectRelationTable: if dict['ProjectID'] == project.projectID: for user in self.users: if dict['UserID'] == user.userID: project.listOfAssignedUsers.append(user) #print('Projects spliced to users in %fms' % ((time.clock() - loopStartTime) * 1000)) loopStartTime = time.clock() for dict in itemToProjectRelationTable: if dict['ProjectID'] == project.projectID: for item in self.items: if dict['ItemID'] == item.itemID: item.projectID = project.projectID project.listOfAssignedItems.append(item) #print('Items Spliced to Projects in %fms' % ((time.clock() - loopStartTime) * 1000)) #self.debugDump() #print('Data Loaded in %fs' % (time.clock()-funcStartTime)) self.isLoading = False return True
from data import ScrumblesData, ScrumblesObjects def printUserDetails(user): print(user.userID) print(user.userName) print(user.userEmailAddress) print(user.userRole) print() login_info = ScrumblesData.DataBaseLoginInfo() login_info.userID = 'test_user' login_info.password = '******' login_info.ipaddress = '173.230.136.241' login_info.defaultDB = 'test' dataConnection = ScrumblesData.ScrumblesData(login_info) dataConnection.connect() userTable = dataConnection.getData(ScrumblesData.Query.getAllUsersQuery) dataConnection.close() listOfAllUsers = [] for row in userTable: user = ScrumblesObjects.User(row) listOfAllUsers.append(user) for user in listOfAllUsers: printUserDetails(user)
assert len(allCommentsQueryResult) >= 0 print('Data Download Successful') listOfUsers = [] listOfSprints = [] listOfItems = [] listOfComments = [] ## Test construction of Objects from Query Results for element in allUsersQueryResult: assert len(element) == 5 assert 'UserID' in element assert 'UserName' in element assert 'UserEmailAddress' in element assert 'UserPassword' in element assert 'UserRole' in element user = ScrumblesObjects.User(element) assert user.userID == element['UserID'] assert user.userName == element['UserName'] assert user.userEmailAddress == element['UserEmailAddress'] assert user.userPassword == element['UserPassword'] assert user.userRole == element['UserRole'] listOfUsers.append(user) assert len(listOfUsers) == len(allUsersQueryResult) for element in allSprintsQueryResult: #assert len(element) == 4 this is dumb, number of sprints change assert 'SprintID' in element assert 'StartDate' in element assert 'DueDate' in element assert 'SprintName' in element sprint = ScrumblesObjects.Sprint(element)