def get_issue_form(global_config, issue_id): global_config['logger'].debug( 'GET Issue Form, Issue: %s', issue_id ) session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season']) users_session = DbSession.open_db_session(global_config['users_db_name'] + global_config['this_season']) issue_id = issue_id platform = issue_id.split('-')[0] issue = IssueTrackerDataModel.getIssue(session, issue_id) form = issueform() form[issue_id_label].value = issue_id form[issue_platform_label].value = platform form[issue_summary_label].value = issue.summary form[issue_status_label].value = issue.status form[issue_priority_label].value = issue.priority # TODO: can also extract the subgroup and taskgroup(component) lists from the # database and override the form with the contents # IssueTrackerDataModel.getSubgroupList() and getTaskgroupList() form[issue_subgroup_label].value = issue.subgroup form[issue_component_label].value = issue.component # apply the valid list of user names to the dropdown # for the owner field and the submitter field username_list = UsersDataModel.getDisplayNameList(users_session) form[issue_owner_label].args = username_list form[issue_submitter_label].args = username_list form[issue_owner_label].value = issue.owner form[issue_submitter_label].value = issue.submitter form[issue_description_label].value = issue.description return form
def get_team_attr_rankings_page(global_config, comp, attr_name): global_config['logger'].debug( 'GET Team Attribute Rankings' ) session = DbSession.open_db_session(global_config['db_name']) attrdef_filename = './config/' + global_config['attr_definitions'] attr_definitions = AttributeDefinitions.AttrDefinitions() attr_definitions.parse(attrdef_filename) attr = attr_definitions.get_definition(attr_name) try: stat_type = attr['Statistic_Type'] except: stat_type = 'Total' web.header('Content-Type', 'application/json') result = [] result.append('{ "rankings": [\n') team_rankings = DataModel.getTeamAttributesInRankOrder(session, comp, attr_name, False) for team in team_rankings: if stat_type == 'Average': value = int(team.cumulative_value/team.num_occurs) else: value = int(team.cumulative_value) data_str = '{ "team": %d, "value": %d }' % (team.team,value) result.append(data_str) result.append(',\n') if len(team_rankings) > 0: result = result[:-1] result.append('\n') result.append(']}') return ''.join(result)
def recalculate_scoring(global_config, competition=None, attr_definitions=None): if competition is None: competition = global_config['this_competition'] + global_config['this_season'] if competition == None or competition == '': raise Exception( 'Competition Not Specified!') # Build the attribute definition dictionary from the definitions csv file if global_config['attr_definitions'] == None: return if attr_definitions is None: attrdef_filename = WebCommonUtils.get_attrdef_filename(competition) if attrdef_filename is not None: attr_definitions = AttributeDefinitions.AttrDefinitions(global_config) attr_definitions.parse(attrdef_filename) else: return session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season']) team_rankings = getTeamsInRankOrder(session, competition) for team_entry in team_rankings: score = calculateTeamScore(session, team_entry.team, competition, attr_definitions) setTeamScore(session, team_entry.team, competition, score) session.commit() dump_database_as_csv_file(session, global_config, attr_definitions, competition) session.remove()
def get_user_form(global_config, username): global_config['logger'].debug( 'GET User Form For: %s', username ) session = DbSession.open_db_session(global_config['users_db_name'] + global_config['this_season']) user = UsersDataModel.getUser(session, username) form = userform() if user: form[user_username_label].value = user.username form[user_emailaddress_label].value = user.email_address form[user_cellphone_label].value = user.cellphone form[user_carrier_label].value = user.carrier form[user_subgroup_label].value = user.subgroup form[user_password_label].value = user.password form[user_display_name_label].value = user.display_name form[user_role_label].value = user.role form[user_contact_mode_label].value = user.contact_mode form[user_nickname_label].value = user.altname form[user_access_level_label].value = user.access_level form[user_state_label].value = user.state form[user_taskgroups_label].value = UsersDataModel.getUserTaskgroups(session, user.username) else: form[user_access_level_label].value = 10 form[user_role_label].value = 'Guest' session.remove() return form
def get_user_list_json(global_config): global_config['logger'].debug( 'GET User List' ) session = DbSession.open_db_session(global_config['users_db_name'] + global_config['this_season']) user_list = UsersDataModel.getUserList(session) session.remove() web.header('Content-Type', 'application/json') result = [] result.append('{ "users" : [\n') for user in user_list: result.append(' { "username": "******", "email_address": "%s", "display_name": "%s", "nickname": "%s", "access_level": "%s", \ "role": "%s", "subgroup": "%s", "contact_mode": "%s", "cellphone": "%s", "carrier": "%s", "state": "%s" }' % \ (user.username,user.email_address,user.display_name,user.altname, user.access_level, user.role, user.subgroup, user.contact_mode, user.cellphone, user.carrier, user.state)) result.append(',\n') if len(user_list) > 0: result = result[:-1] result.append(' ] }\n') return ''.join(result)
def delete_comment(global_config, competition, match_str, tag): session = DbSession.open_db_session(global_config["debriefs_db_name"] + global_config["this_season"]) DebriefDataModel.deleteDebriefCommentsByTag(session, competition, match_str, tag) session.commit() return "/debrief/%s/%s" % (competition, match_str)
def process_form(global_config, form): global_config['logger'].debug( 'Process Attribute Modify Form' ) season = form[attr_modify_season_label].value comp = form[attr_modify_comp_label].value team = form[attr_modify_team_number_label].value attr_name = form[attr_modify_attribute_name_label].value old_value = form[attr_modify_old_value_label].value new_value = form[attr_modify_new_value_label].value # Initialize the database session connection db_name = global_config['db_name'] + global_config['this_season'] session = DbSession.open_db_session(db_name) attrdef_filename = WebCommonUtils.get_attrdef_filename(short_comp=comp) if attrdef_filename is not None: attr_definitions = AttributeDefinitions.AttrDefinitions(global_config) attr_definitions.parse(attrdef_filename) attr_def = attr_definitions.get_definition(attr_name) try: DataModel.modifyAttributeValue(session, team, comp+season, attr_name, old_value, new_value, attr_def) result = 'Attribute %s Modified From %s to %s For Team %s' % (attr_name,old_value,new_value,team) session.commit() except ValueError as reason: result = 'Error Modifying Scouting Addribute %s For Team %s: %s' % (attr_name,team,reason) session.remove() return result
def process_files(global_config, attr_definitions, input_dir, recursive=True): start_time = datetime.datetime.now() # Initialize the database session connection db_name = global_config['db_name'] session = DbSession.open_db_session(db_name) some_files_processed = False # The following regular expression will select all files that conform to # the file naming format Team*.txt. Build a list of all datafiles that match # the naming format within the directory passed in via command line # arguments. file_regex = re.compile('Team[a-zA-Z0-9_]+.txt') files = get_files(global_config, session, db_name, input_dir, file_regex, recursive) print 'files retrieved, elapsed time - %s' % (str(datetime.datetime.now()-start_time)) # Process data files for data_filename in files: try: process_file( global_config, session, attr_definitions, data_filename) except Exception, e: # log the exception but continue processing other files log_exception(global_config['logger'], e) # add the file to the set of processed files so that we don't process it again. Do it outside the # try/except block so that we don't try to process a bogus file over and over again. DataModel.addProcessedFile(session, data_filename) some_files_processed = True # Commit all updates to the database session.commit()
def get_team_participation_json(): team_participation = {} filename = "team_participation" my_config = ScoutingAppMainWebServer.global_config session = DbSession.open_db_session(my_config["db_name"] + my_config["this_season"]) teams = session.query(DataModel.TeamInfo).all() for team in teams: team_key = "frc%d" % team.team if team.first_competed is not None: info = {} info["first_competed"] = team.first_competed info["last_competed"] = team.last_competed team_participation[team_key] = info team_participation_json = json.dumps(team_participation) team_participation_js = "var %s = '%s';" % (filename, team_participation_json) # store the geo location information to a file, too try: FileSync.put(my_config, "GlobalData/%s.json" % (filename), "text", team_participation_json) FileSync.put(my_config, "GlobalData/%s.js" % (filename), "text", team_participation_js) except: raise return team_participation_json
def get_team_list_json(global_config, comp): global team_info_dict global_config['logger'].debug( 'GET Team List For Competition %s', comp ) session = DbSession.open_db_session(global_config['db_name']) web.header('Content-Type', 'application/json') result = [] result.append('{ "teams" : [\n') team_list = DataModel.getTeamsInNumericOrder(session, comp) for team in team_list: team_info = None # TODO - Remove this hardcoded number for the valid team number. This check prevents # requesting information for invalid team numbers, which has been known to happen when # tablet operators enter bogus team numbers by mistake if team.team < 10000: team_info = DataModel.getTeamInfo(session, int(team.team)) if team_info: result.append(' { "team_number": "%s", "nickname": "%s" }' % (team.team,team_info.nickname)) result.append(',\n') if len(team_list) > 0: result = result[:-1] result.append(' ] }\n') return ''.join(result) else: return get_team_list_json_from_tba(global_config, comp)
def process_files(global_config, attr_definitions, input_dir, recursive=True): start_time = datetime.datetime.now() # Initialize the database session connection db_name = global_config["db_name"] + global_config["this_season"] session = DbSession.open_db_session(db_name) some_files_processed = False # read the ignore file list config each time through the loop. Any files # in the ignore list will be skipped ignore_filelist = read_ignore_filelist_cfg(input_dir + "IgnoreFiles.txt") # The following regular expression will select all files that conform to # the file naming format Team*.txt. Build a list of all datafiles that match # the naming format within the directory passed in via command line # arguments. file_regex = re.compile("Team[a-zA-Z0-9_]+.txt") files = get_files(global_config, session, db_name, input_dir, file_regex, recursive) if len(files) > 0: log_msg = "files retrieved, elapsed time - %s" % (str(datetime.datetime.now() - start_time)) print log_msg global_config["logger"].debug("%s - %s" % (process_files.__name__, log_msg)) global_config["logger"].debug("%s - %d Files to be processed" % (process_files.__name__, len(files))) # Process data files for data_filename in files: # If the file is on the ignore list (quarantined), then skip it if data_filename.split("/")[-1] in ignore_filelist: global_config["logger"].debug("%s - Ignoring file: %s" % (process_files.__name__, data_filename)) continue # Make sure that the data file has not already been processed. We have seen cases # where the data file gets inserted into the list of files to be processed more than # once. file_processed = isFileProcessed(global_config, session, db_name, data_filename) if not file_processed: try: global_config["logger"].debug("%s - Processing file: %s" % (process_files.__name__, data_filename)) process_file(global_config, session, attr_definitions, data_filename) except Exception, e: global_config["logger"].debug( "%s - Error processing file: %s" % (process_files.__name__, data_filename) ) # log the exception but continue processing other files log_exception(global_config["logger"], e) # add the file to the set of processed files so that we don't process it again. Do it outside the # try/except block so that we don't try to process a bogus file over and over again. DataModel.addProcessedFile(session, data_filename) some_files_processed = True else: global_config["logger"].debug( "%s - Skipping file: %s, already processed" % (process_files.__name__, data_filename) ) # Commit all updates to the database session.commit()
def get_event_geo_location(global_config, event_key=None): session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season']) DataModel.setEventsGeoLocation(session, event_key) session.remove()
def auth_user(global_config, desired_path='/home'): auth = web.ctx.env.get('HTTP_AUTHORIZATION') authreq = False if auth is None: authreq = True else: auth = re.sub('^Basic ','',auth) username,password = base64.decodestring(auth).split(':') if logged_out_users.has_key(username): del logged_out_users[username] else: session = DbSession.open_db_session(global_config['users_db_name'] + global_config['this_season']) user = UsersDataModel.getUser(session, username) session.remove() if user: if user.state == 'Disabled': raise web.seeother('/accountdisabled') #if (username,password) in allowed: if user.check_password(password) == True: raise web.seeother(desired_path) authreq = True if authreq: web.header('WWW-Authenticate','Basic realm="FRC1073 ScoutingAppCentral"') web.ctx.status = '401 Unauthorized' return
def process_delete_attr_form(global_config, form): global_config['logger'].debug( 'Process Attribute Delete Form' ) season = form[attr_delete_season_label].value comp = form[attr_delete_comp_label].value team = form[attr_delete_team_number_label].value attr_name = form[attr_delete_attribute_name_label].value old_value = form[attr_delete_old_value_label].value # Initialize the database session connection db_name = global_config['db_name'] + global_config['this_season'] session = DbSession.open_db_session(db_name) attrdef_filename = WebCommonUtils.get_attrdef_filename(short_comp=comp) if attrdef_filename is not None: attr_definitions = AttributeDefinitions.AttrDefinitions(global_config) attr_definitions.parse(attrdef_filename) attr_def = attr_definitions.get_definition(attr_name) try: DataModel.deleteAttributeValue(session, team, comp+season, attr_name, old_value, attr_def) result = 'Scouting Data Attribute Value %s Successfully Removed From %s' % (old_value,attr_name) session.commit() except ValueError as reason: result = 'Error Removing Scouting Data Attribute Value %s From %s: %s' % (old_value,attr_name,reason) session.remove() return result
def process_delete_file_form(global_config, form): global_config['logger'].debug( 'Process Attribute Delete Form' ) data_filename = form[attr_delete_file_label].value if form[attr_remove_file_processed_label].value == 'Yes': remove_from_processed_files = True else: remove_from_processed_files = False # Initialize the database session connection db_name = global_config['db_name'] + global_config['this_season'] session = DbSession.open_db_session(db_name) attrdef_filename = WebCommonUtils.get_attrdef_filename(short_comp=global_config['this_competition']) if attrdef_filename is not None: attr_definitions = AttributeDefinitions.AttrDefinitions(global_config) attr_definitions.parse(attrdef_filename) try: ProcessFiles.remove_file_data(global_config, session, attr_definitions, \ data_filename, remove_from_processed_files) result = 'Scouting Data File %s Attributes Successfully Removed' % (data_filename) session.commit() except ValueError as reason: result = 'Error Removing Scouting Data File %s: %s' % (data_filename, reason) session.remove() return result
def get_team_score_json(global_config, name, comp, store_json_file=False): global_config['logger'].debug( 'GET Team %s Score For Competition %s', name, comp ) season = WebCommonUtils.map_comp_to_season(comp) session = DbSession.open_db_session(global_config['db_name'] + season) result = [] result.append('{ "competition" : "%s", "team" : "%s", ' % (comp,name)) team_scores = DataModel.getTeamScore(session, name, comp) if len(team_scores)==1: result.append('"score": "%s" }' % team_scores[0].score) else: result.append(' "score": [') for score in team_scores: result.append(score.json()) result.append(',\n') if len(team_scores) > 0: result = result[:-1] result.append(']}') json_str = ''.join(result) if store_json_file is True: try: FileSync.put( global_config, '%s/EventData/TeamData/team%s_scouting_score.json' % (comp,name), 'text', json_str) except: raise session.remove() return json_str
def get_team_scouting_notes_json(global_config, comp, name, store_json_file=False): global_config['logger'].debug( 'GET Team %s Scouting Notes For Competition %s', name, comp ) season = WebCommonUtils.map_comp_to_season(comp) session = DbSession.open_db_session(global_config['db_name'] + season) result = [] result.append('{ "competition" : "%s", "team" : "%s",\n' % (comp,name)) result.append(' "scouting_notes" : [\n') team_notes = DataModel.getTeamNotes(session, name, comp) for note in team_notes: result.append(' { "tag": "%s", "note": "%s" }' % (note.tag,note.data)) result.append(',\n') if len(team_notes) > 0: result = result[:-1] result.append(' ] }\n') json_str = ''.join(result) if store_json_file is True: try: FileSync.put( global_config, '%s/EventData/TeamData/team%s_scouting_notes.json' % (comp,name), 'text', json_str) except: raise session.remove() return json_str
def get_issue_json(global_config, issue_id, allow_update=False): session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season']) issue = IssueTrackerDataModel.getIssue(session, issue_id) if issue: return issue.json() else: return None
def load_team_participation_years( global_config, team_number=None): session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season']) if team_number is None: global_config['logger'].debug( 'Loading Team Participation Info For All FRC Teams' ) teams = session.query(DataModel.TeamInfo).all() for team in teams: if team.first_competed is None: print 'Getting participation years for FRC%d' % team.team url_str = '/api/v2/team/frc%d/years_participated' % team.team team_data = TbaIntf.get_from_tba_parsed(url_str) if len(team_data) > 0: team.first_competed = team_data[0] team.last_competed = team_data[-1] session.commit() else: team = session.query(DataModel.TeamInfo).filter(DataModel.TeamInfo.team==int(team_number)).first() if team: url_str = '/api/v2/team/frc%s/years_participated' % team_number team_data = TbaIntf.get_from_tba_parsed(url_str) if len(team_data) > 0: team.first_competed = team_data[0] team.last_competed = team_data[-1] session.commit() session.remove() return
def update_team_data_files( global_config, year, event, directory, team=None ): global_config['logger'].debug( 'Updating Team DataFiles' ) session = DbSession.open_db_session(global_config['db_name'] + year) comp = event+year result = False team_list = [] if team == None or team == '': team_list = DataModel.getTeamsInNumericOrder(session, comp) else: team_list.append(team) # for now, we only support updating files in the TeamData directory, so only continue if that's the # directory that was specified. if directory.upper() == 'TEAMDATA' or directory.upper() == 'EVENTDATA': for team_entry in team_list: # TODO: added a special test here to skip teams with a number greater than 10000. Some data # was erroneously entered with team numbers really high... if team_entry.team < 10000: get_team_info_json(global_config, comp, team_entry.team, store_json_file=True) get_team_score_json(global_config, team_entry.team, comp, store_json_file=True) get_team_score_breakdown_json(global_config, team_entry.team, comp, store_json_file=True) get_team_scouting_notes_json(global_config, comp, team_entry.team, store_json_file=True) get_team_scouting_mediafiles_json(global_config, comp, str(team_entry.team), store_json_file=True) get_team_scouting_datafiles_json(global_config, comp, str(team_entry.team), store_json_file=True) get_team_scouting_data_summary_json(global_config, comp, team_entry.team, attr_filter=[], filter_name=None, store_json_file=True) result = True session.remove() return result
def load_team_info( global_config, name=None): session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season']) if name is None: global_config['logger'].debug( 'Loading Team Info For All FRC Teams' ) page = 0 done = False while not done: url_str = '/api/v2/teams/%d' % (page) teams_data = TbaIntf.get_from_tba_parsed(url_str) if len(teams_data) == 0: done = True else: for team_data in teams_data: DataModel.setTeamInfoFromTba(session, team_data) page += 1 else: global_config['logger'].debug( 'Loading Team Info For FRC Team %s' % name ) ''' url_str = '/api/v2/team/frc%s/%s' % (team_str,query_str) for page in range(0,14): teams_data = TbaIntf.get_from_tba_parsed(url_str) for team_data in teams_data: setTeamInfoFromTba(session, team_data) ''' session.remove()
def get_platform_issues(global_config, platform_type, status=''): global_config['logger'].debug( 'GET Issues for platform: %s', platform_type ) session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season']) if status.lower() == 'open': issues = IssueTrackerDataModel.getIssuesByPlatformAndMultipleStatus(session, platform_type, 'Open', 'Working', order_by_priority=True) elif status.lower() == 'closed': issues = IssueTrackerDataModel.getIssuesByPlatformAndMultipleStatus(session, platform_type, 'Closed', 'Resolved') else: issues = IssueTrackerDataModel.getIssuesByPlatform(session, platform_type, status) web.header('Content-Type', 'application/json') result = [] result.append('{ "issues": [\n') for issue in issues: result.append(issue.json()) result.append(',\n') if len(issues) > 0: result = result[:-1] result.append('\n') result.append(']}') session.remove() return ''.join(result)
def recalculate_scoring(global_config, competition=None, attr_definitions=None): session = DbSession.open_db_session(global_config['db_name']) if competition is None: competition = global_config['this_competition'] + global_config['this_season'] if competition == None or competition == '': raise Exception( 'Competition Not Specified!') # Build the attribute definition dictionary from the definitions csv file #attrdef_filename = './config/' + 'AttributeDefinitions-reboundrumble.csv' if global_config['attr_definitions'] == None: return if attr_definitions is None: attrdef_filename = './config/' + global_config['attr_definitions'] attr_definitions = AttributeDefinitions.AttrDefinitions() attr_definitions.parse(attrdef_filename) team_rankings = getTeamsInRankOrder(session, competition) for team_entry in team_rankings: score = calculateTeamScore(session, team_entry.team, competition, attr_definitions) setTeamScore(session, team_entry.team, competition, score) session.commit() dump_database_as_csv_file(session, global_config, attr_definitions, competition) session.close()
def get_team_info_json(global_config, comp, name, store_json_file=False): global_config['logger'].debug( 'GET Team %s Info', name ) season = WebCommonUtils.map_comp_to_season(comp) session = DbSession.open_db_session(global_config['db_name'] + season) team_info = DataModel.getTeamInfo(session, int(name)) if team_info is None: json_str = '' else: result = [] result.append('{ "team": "%s", "team_data" : [\n' % name) result.append(' { "name": "%s", "value": "%s" }' % ('nickname', team_info.nickname)) result.append(',\n') result.append(' { "name": "%s", "value": "%s" }' % ('affiliation', team_info.fullname)) result.append(',\n') result.append(' { "name": "%s", "value": "%s" }' % ('location', team_info.location)) result.append(',\n') result.append(' { "name": "%s", "value": "%s" }' % ('rookie_season', team_info.rookie_season)) result.append(',\n') result.append(' { "name": "%s", "value": "%s" }' % ('website', team_info.website)) result.append('\n') result.append(' ] }\n') json_str = ''.join(result) if store_json_file is True: try: FileSync.put( global_config, '%s/EventData/TeamData/team%s_teaminfo.json' % (comp,name), 'text', json_str) except: raise return json_str
def get_geo_location_json(include_teams=True, include_events=True): geo_locations = {} filename = "geo_coordinates_for" my_config = ScoutingAppMainWebServer.global_config session = DbSession.open_db_session(my_config["db_name"] + my_config["this_season"]) if include_events: filename += "_Events" events = session.query(DataModel.EventInfo).all() for event in events: if event.geo_location is not None: geo_locations[event.event_key] = json.loads(event.geo_location) if include_teams: filename += "_Teams" teams = session.query(DataModel.TeamInfo).all() for team in teams: if team.geo_location is not None: team_key = "frc%d" % team.team geo_locations[team_key] = json.loads(team.geo_location) geo_location_json = json.dumps(geo_locations) geo_location_js = "var %s = '%s';" % (filename, geo_location_json) # store the geo location information to a file, too try: FileSync.put(my_config, "GlobalData/%s.json" % (filename), "text", geo_location_json) FileSync.put(my_config, "GlobalData/%s.js" % (filename), "text", geo_location_js) except: raise return geo_location_json
def delete_comment(global_config, issue_id, tag): session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season']) IssueTrackerDataModel.deleteIssueCommentsByTag(session, issue_id, tag) session.commit() return '/issue/%s' % issue_id
def load_event_info(global_config, year_str): session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season']) if year_str.lower() == 'all': # get all events since the beginning of time year = 1992 done = False while not done: url_str = '/api/v2/events/%d' % year events_data = TbaIntf.get_from_tba_parsed(url_str) if len(events_data) == 0: done = True else: for event_data in events_data: #print 'Event: %s' % event_data['key'] DataModel.addOrUpdateEventInfo(session, event_data) year += 1 else: url_str = '/api/v2/events/%s' % year_str events_data = TbaIntf.get_from_tba_parsed(url_str) for event_data in events_data: print 'Event: %s' % event_data['key'] DataModel.addOrUpdateEventInfo(session, event_data) session.commit() session.remove()
def set_team_geo_location(global_config, team_key=None): session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season']) DataModel.setTeamGeoLocation(session, team_key) session.remove()
def get_team_comp_list(this_comp, team): my_config = ScoutingAppMainWebServer.global_config complist = list() if this_comp == None: this_comp = my_config["this_competition"] + my_config["this_season"] season = my_config["this_season"] else: season = map_comp_to_season(this_comp) complist.append(this_comp) team_complist = WebTeamData.get_team_event_list_from_tba(my_config, team, season) if not team_complist: session = DbSession.open_db_session(my_config["db_name"] + my_config["this_season"]) team_scores = DataModel.getTeamScore(session, team) for score in team_scores: comp = score.competition.upper() # currently, the competition season is stored in the database # as part of the competition. So, we need to add it for the comparison, # but not as we define the complist itself if comp != this_comp.upper(): complist.append(comp) else: for comp in team_complist: if comp.upper() != this_comp.upper(): complist.append(comp) return complist
def process_delete_user(global_config, username): global_config['logger'].debug( 'Process Delete User' ) session = DbSession.open_db_session(global_config['users_db_name'] + global_config['this_season']) UsersDataModel.deleteUser(session, username) session.commit() session.remove() return '/users'