def __event_tab_selection_changed(self, index): self.__clear_listwidget(self.listWidget_matchslist) if index == 1: matchs = dao.getMatch().getMatchPlayed(self.get_competition()) if matchs is not None: self.progressBar_competitionlevel.setValue(len(matchs)) teams = dao.getTeam().getAll(self.get_competition()) monClassement = Classement(teams) if matchs is not None: for match in matchs: team_dom = dao.getTeam().getById(match.idteam_home) team_ext = dao.getTeam().getById(match.idteam_outside) score_dom = 0 score_ext = 0 goals = dao.getGoals().getByMatch(match) if goals is not None: for goal in goals: if goal.idequipe == team_dom.id: score_dom += 1 else: score_ext += 1 monClassement.add_score(team_dom, score_dom, score_ext, team_ext) self.listWidget_matchslist.addItem( '{} {} - {} {}'.format(team_dom.name, score_dom, score_ext, team_ext.name)) self.__update_result(monClassement)
def __update_view_for_current_match(self, o_match): self.__clear_listwidget(self.listWidget_domplayer) self.__clear_listwidget(self.listWidget_extplayer) self.__clear_listwidget(self.listWidget_matchevent) if o_match is not None: o_tdom = dao.getTeam().getById(o_match.idteam_home) o_tvis = dao.getTeam().getById(o_match.idteam_outside) self.textEdit_dom.setText(o_tdom.name) self.textEdit_vis.setText(o_tvis.name) self.textEdit_domscore.setText('0') self.textEdit_extscore.setText('0') playerteamdom = dao.getPlayer().getByTeam(o_tdom) for player in playerteamdom: self.listWidget_domplayer.addItem(player.description) playerteamext = dao.getPlayer().getByTeam(o_tvis) for player in playerteamext: self.listWidget_extplayer.addItem(player.description) # if there are goal listgoal = dao.getGoals().getByMatch(o_match) if listgoal is not None: for goal in listgoal: oteam = dao.getTeam().getById(goal.idequipe) oscorer = dao.getPlayer().getById(goal.idplayer_scorer) oass = dao.getPlayer().getById(goal.idplayer_ass) self.__update_view_after_goals(oteam, oscorer, oass)
def __event_bt_addteam(self, checked): message = 'please can you input the name of the team?' text, yespressed = QInputDialog.getText(None, "Add team", message, QLineEdit.Normal, "") if yespressed and text is not None: o = model.getTeamProvider().get_new(self.get_competition().id, text) dao.getTeam().insert(o) self.__refresh_tab1() self.set_current_team(o)
def __event_bt_after_goals(self): match = self.get_current_match() oteamdom = dao.getTeam().getById(match.idteam_home) playersdom = dao.getPlayer().getByTeam(oteamdom) oteamvis = dao.getTeam().getById(match.idteam_outside) playersext = dao.getPlayer().getByTeam(oteamvis) dialog = GoalWindow(self, oteamdom, playersdom, oteamvis, playersext) btpressed = dialog.exec() if btpressed: oteam, oscorer, oass = dialog.get_datas() but = model.getGoalsProvider().get_new( oscorer.id if oscorer is not None else None, match.id, oteam.id, oass.id if oass is not None else None) dao.getGoals().insert(but) self.__update_view_after_goals(oteam, oscorer, oass)
def __after_changed_property_competition(self, o_competition): if o_competition is not None: self.setWindowTitle(o_competition.name) self.set_teams(dao.getTeam().getAll(o_competition)) self.tabWidget.setEnabled(True) else: self.tabWidget.setEnabled(False)
def __update_view_after_goals(self, oteam, oscorer, oass): text = 'GOAL for {}\n\tscorer: {}\n\tass: {}\n==============='.format( oteam.name, oscorer.description if oscorer is not None else 'own goal', oass.description if oass is not None else 'none') team_dom = dao.getTeam().getById(self.get_current_match().idteam_home) txtedit = self.textEdit_domscore if oteam == team_dom else self.textEdit_extscore score = int(txtedit.toPlainText()) score += 1 txtedit.setText(str(score)) self.listWidget_matchevent.addItem(text)
from datetime import datetime from model.dao.daofactory import DaoFactory as dao from model.provider.modelfactory import ModelFactory as model from service.service_provider import ServiceProvider as service o = len(dao.getCompetition().getAll()) if o == 0: chp = model.getCompetitionProvider().get_standard_competition( "ma competition") dao.getCompetition().insert(chp) team1 = model.getTeamProvider().get_new("Liverpool") dao.getTeam().insert(team1, chp) team2 = model.getTeamProvider().get_new("Chelsea") dao.getTeam().insert(team2, chp) team3 = model.getTeamProvider().get_new("Arsenal") dao.getTeam().insert(team3, chp) team4 = model.getTeamProvider().get_new("Manchester") dao.getTeam().insert(team4, chp) pl1 = model.getPlayerProvider().get_randomplayer() pl2 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl1, team1, team1.name) dao.getPlayer().insert(pl2, team1, team1.name) pl3 = model.getPlayerProvider().get_randomplayer() pl4 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl3, team2, team2.name) dao.getPlayer().insert(pl4, team2, team2.name) pl5 = model.getPlayerProvider().get_randomplayer() pl6 = model.getPlayerProvider().get_randomplayer() dao.getPlayer().insert(pl5, team3, team3.name) dao.getPlayer().insert(pl6, team3, team3.name)
def __event_bt_deleteteam(self, checked): if dao.getTeam().delete(self.get_current_team()): self.__refresh_tab1()
self.teams[oteam1][0] += 1 self.teams[oteam2][2] += 1 else: self.teams[oteam1][2] += 1 self.teams[oteam2][0] += 1 self.teams[oteam1][3] += score1 self.teams[oteam1][4] += score2 self.teams[oteam2][3] += score2 self.teams[oteam2][4] += score1 model = ModelFactory() dao = DaoFactory() service = ServiceProvider() ch = dao.getCompetition().getById(1) teams = dao.getTeam().getAll(ch) monClassement = Classement(teams) monClassement.show() matchs = dao.getMatch().getMatchPlayed(ch) for match in matchs: team_dom = dao.getTeam().getById(match.idteam_home) team_ext = dao.getTeam().getById(match.idteam_outside) score_dom = 0 score_ext = 0 goals = dao.getGoals().getByMatch(match) for goal in goals: if goal.idequipe == team_dom.id: score_dom += 1 else: score_ext += 1