class Team(): def __init__(self, team_id): self.team_id = team_id self.db = GateWay() def add_member(self,user_id): return self.db.add_to_team(self.team_id, user_id) def get_team_members(self): return self.db.get_team_devs(self.team_id) def get_current_projects(self): return self.db.get_team_current_projects(self.team_id) def get_history_projects(self): return self.db.get_team_finished_projects(self.team_id)
class ApplicationManager(): def __init__(self): self.apps = [] self.db = GateWay() def read(self): self.apps = [] list = self.db.get_applications() for app in list: self.apps.append(User(app[0])) def accept(self, i): self.db.approve_user_id(self.apps[i].user_id) def reject(self, i, reason): self.db.add_blacklist(self.apps[i].user_id, reason)
def search(self, keyword): db = GateWay() # empty all result list self.users = [] self.teams = [] self.idprojs = [] self.teamprojs = [] userlist = db.search_by_user_id(keyword) for i in range(len(userlist)): self.users.append(User(userlist[i][0])) teamlist = db.search_by_team_id(keyword) for i in range(len(teamlist)): self.teams.append(Team(teamlist[i][0])) self.idprojs = db.search_by_indivprojectid(keyword) self.teamprojs = db.search_by_teamprojectid(keyword)
def login(self, user_id, password): db = GateWay() if db.check_blacklist(user_id): self.currentUser = None return "You are blocked: " + db.get_black_list(user_id)[0][2] elif db.verify_user(user_id, password): user_type = db.get_user_type(user_id) if user_type == 0: self.currentUser = SuperUser(user_id) elif user_type == 1: self.currentUser = Client(user_id) # Any client with inadequate fund to fulfill a bid will be warned automatically and the posted project nullified db.check_client_projects(self.currentUser.user_id) db.check_client_projects2(self.currentUser.user_id) else: self.currentUser = Developer(user_id) if db.check_warning_number(user_id) >= 2: db.add_blacklist( user_id, "Due to your low performance, you have been add to the blacklist" ) return "This is your last time login" return "Welcome" else: self.currentUser = None return "INVALID USER ID OR PASSWORD"
def __init__(self, team_id): self.team_id = team_id self.db = GateWay()
def __init__(self, project_id, client_id, description, deadline): self.project_id = project_id self.client_id = client_id self.description = description self.deadline = deadline self.db = GateWay()
def main(): Manager = GateWay() # check_blacklist testAndPrint(Manager.check_blacklist("testuser2"),False) # verify_user testAndPrint(Manager.verify_user('if','2'), False) testAndPrint(Manager.verify_user('testuser2','test'),False) testAndPrint(Manager.verify_user('testuser2','password2'),True) # add testuser4 to blacklist, then remove testAndPrint(Manager.add_blacklist('testuser4', 'testing'), True) testAndPrint(Manager.clear_blacklist(), True) # check if testuser2 is client testAndPrint(Manager.get_user_type('testuser2'), 1) # update test user balance and check if update successful testAndPrint(Manager.update_user_balance('testuser3', 2000.00), True) testAndPrint(Manager.get_user_balance('testuser3'), 'user balance') # test get_user_address, and update user_address testAndPrint(Manager.get_user_address('testuser2'), '123 40th St. Queens, NY') testAndPrint(Manager.set_user_address('testuser4', '456 70th Street, Queens, NY'), True) # test set_user_password testAndPrint(Manager.set_user_password('testuser4', 'password'), True) #test set and get_user_email testAndPrint(Manager.set_user_email('testuser4', '*****@*****.**'), True) testAndPrint(Manager.get_user_email('testuser4'), '*****@*****.**') # test add_user and approve user id, then remove user so test will pass next time testAndPrint(Manager.add_user('testremove', '', 10000, 1, '*****@*****.**', '100 Convent Ave. NY, NY'), True) testAndPrint(Manager.approve_user_id('testremove'), True) testAndPrint(Manager.delete_account('testremove'), True) # test total number of devs and clients testAndPrint(Manager.get_dev_num(), 5) testAndPrint(Manager.get_client_num(), 6) # test most active client and dev with most income, may fail when i edit tables more testAndPrint(Manager.get_active_clients(3), '3 clients') testAndPrint(Manager.get_active_devs(3), '3 devs') # test adding a new project, insert team bids, individual bids, and then choose one bid, then finish the project and delete record. testAndPrint(Manager.delete_project('testproject'), True) testAndPrint(Manager.create_new_project('testproject', 'testuser2', 'testproject', '2017-12-30', 1000, '2017-12-20'), True) testAndPrint(Manager.place_team_bid('testproject', 'testteam1', 500), True) testAndPrint(Manager.place_team_bid('testproject', 'testteam2', 250), True) testAndPrint(Manager.place_team_bid('testproject', 'testteam3', 600), True) testAndPrint(Manager.place_individual_bid('testproject', 'testuser4', 700), True) testAndPrint(Manager.place_individual_bid('testproject', 'testuser6', 600), True) testAndPrint(Manager.get_pending_projects(), '\n\nPendingProjects\n') testAndPrint(Manager.get_lowest_bid('testproject'), 'Lowest bid = 250') testAndPrint(Manager.get_individual_project_bids('testproject'), (('testuser6', 600.00), ('testuser4', 700.00))) testAndPrint(Manager.get_team_project_bids('testproject'), (('testteam2', 250.00), ('testteam1', 500.00), ('testteam3', 600.00))) testAndPrint(Manager.choose_team('testproject', 'testteam1', 500.00), True) testAndPrint(Manager.get_project_status('testproject'), 'Current') testAndPrint(Manager.get_project_type('testproject'), 'Team') testAndPrint(Manager.finish_team_project('testproject'), True) testAndPrint(Manager.create_team_project_review('testproject', 5, 'Good Project'), True) testAndPrint(Manager.get_dev_pending_reviews('testuser4', 'testproject'), 'pending reviews') testAndPrint(Manager.create_project_review('testproject', 'testuser4', 'testuser6', 5, 'gz'), True) testAndPrint(Manager.create_project_review('testproject', 'testuser6', 'testuser4', 5, 'gz'), True) testAndPrint(Manager.get_projectreviews('testuser6'), 'user6\'s project reviews') testAndPrint(Manager.get_applications(), 'applications') # makes another test project print('Testing project 2...\n\n') testAndPrint(Manager.delete_project('testproject2'), True) testAndPrint(Manager.create_new_project('testproject2', 'testuser5', 'testproject2', '2017-12-29', 1000, '2017-12-10'), True) testAndPrint(Manager.place_team_bid('testproject2', 'testteam2', 600.00), True) testAndPrint(Manager.choose_team('testproject2', 'testteam2', 600.00), True) testAndPrint(Manager.finish_team_project('testproject2'), True) testAndPrint(Manager.create_team_project_review('testproject2', 1, 'Bad Review'), True) testAndPrint(Manager.get_bad_projects(), 'list of bad projects') testAndPrint(Manager.settle_project_dispute('testproject2', 3, 600.00), True) testAndPrint(Manager.get_dev_pending_reviews('testuser4', 'testproject2'), 'user\'s pending reviews') testAndPrint(Manager.create_project_review('testproject2', 'testuser4', 'testuser5', 4, 'good project'), True) testAndPrint(Manager.create_project_review('testproject2', 'testuser4', 'testuser6', 2, ''), True) print('Done testing project 2...\n\n') # tests an individual project print('Testing project 3 (individual)\n\n') testAndPrint(Manager.delete_project('testproject3'), True) testAndPrint(Manager.create_new_project('testproject3', 'testuser5', 'indiv project', '2017-12-30', 5000, '2017-12-20'), True) testAndPrint(Manager.place_individual_bid('testproject3', 'testuser6', 300.00), True) testAndPrint(Manager.choose_dev('testproject3', 'testuser6', 300.00), True) testAndPrint(Manager.finish_individual_project('testproject3'), True) testAndPrint(Manager.create_project_review('testproject3', 'testuser5', 'testuser6', 4, 'Good review'), True) testAndPrint(Manager.get_dev_pending_reviews('testuser6', 'testproject3'), 'user\'s pending reviews') testAndPrint(Manager.create_project_review('testproject3', 'testuser6', 'testuser5', 3, 'good review'), True) print('Finished testing project3 (Individual project)\n\n') testAndPrint(Manager.get_lowest_bid('4'), 'No bids') # test getting user interests, and then ordering users by their interests testAndPrint(Manager.get_user_interests('testuser6'), (0, 0, 0, 1, 1, 1)) testAndPrint(Manager.get_similar_interests('testuser6'), 'all users ordered by interests shared') # test searching functions testAndPrint(Manager.search_by_user_id('testuser'), 'list of all users with similar name') testAndPrint(Manager.search_by_team_id('testteam'), 'list of all teams with similar name') testAndPrint(Manager.search_by_teamprojectid('5'), 'list of projects') testAndPrint(Manager.search_by_indivprojectid('6'), 'list of projects') testAndPrint(Manager.new_message('testuser4', 'testuser6', 'testmessage'), '') testAndPrint(Manager.get_teams_users('testteam1'), '') testAndPrint(Manager.get_users_teams('testuser6'), 'user\'s teams') testAndPrint(Manager.get_team_projecthistory('testteam1'), 'teams project history') testAndPrint(Manager.get_devs_finished_team_projects('testuser4'), 'user4\'s team project history')
def __init__(self, user_id): self.user_id = user_id self.db = GateWay()
class User(): def __init__(self, user_id): self.user_id = user_id self.db = GateWay() def update_password(self, new_password): return self.db.set_user_password(self.user_id, new_password) def get_balance(self): return self.db.get_user_balance(self.user_id) def update_balance(self, new_balance): return self.db.update_user_balance(self.user_id, new_balance) def get_email(self): return self.db.get_user_email(self.user_id) def update_email(self, new_email): return self.db.set_user_email(self.user_id, new_email) def get_address(self): return self.db.get_user_address(self.user_id) def update_address(self, new_address): return self.db.update_address(self.user_id, new_address) # return () if no transaction history def get_transaction_history(self): return self.db.get_transaction_history(self.user_id, self.user_id) def get_inbox_message(self): return self.db.get_inbox_message(self.user_id) def get_sent_message(self): return self.db.get_sent_message(self.user_id) def new_message(self, receiver, message): return self.db.new_message(self.user_id, receiver, message) def interests(self): return self.db.get_user_interests(self.user_id) def type(self): user_type = self.db.get_user_type(self.user_id) if user_type == 0: return "Super User" elif user_type == 1: return "Client" else: return "Develop" def black_reason(self): return self.db.get_black_list(self.user_id)[0] def rating(self): try: return round(self.db.average_rating(self.user_id), 2) except TypeError: return None def get_review(self): return self.db.get_projectreviews(self.user_id, self.user_id) def check_application(self): return self.db.check_application(self.user_id)
def __init__(self): self.apps = [] self.db = GateWay()
def __init__(self): self.dev = [] self.teams = [] self.db = GateWay()