def __event_create_competition(self): # create competition with user's name name, bt = QInputDialog.getText(None, 'New competition', "Enter your competition's name:", text='choose') if bt: c = model.getCompetitionProvider().get_standard_competition(name) dao.getCompetition().insert(c) self.set_competition(c)
def __event_load_competition(self, p_index): # loading existing competition compet = dao.getCompetition().getById(p_index) self.set_competition(compet) if dao.getMatch().getAll(self.get_competition()) is not None: print('la competition a déjà commencé') self.set_competition_begin(True)
def __menu_open_competitions(self): competitions = dao.getCompetition().getAll() if competitions is not None: for competition in competitions: name = competition.name idenreg = competition.id obj = QAction(name, self) obj.triggered.connect(lambda chk, item=idenreg: self. __event_load_competition(item)) self.menuOpen.addAction(obj)
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)
elif score1 > score2: 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: