Пример #1
0
 def __after_changed_property_competition_begin(self, compet_start):
     self.pushButton_deleteplayer.setEnabled(not compet_start)
     self.pushButton_deleteteam.setEnabled(not compet_start)
     self.actionStart.setEnabled(not compet_start)
     if compet_start:
         self.progressBar_competitionlevel.setMaximum(
             len(dao.getMatch().getAll(self.get_competition())))
         self.tableWidget_competitionresult.setRowCount(
             len(self.get_teams()))
         match = dao.getMatch().getNextMatch(self.get_competition())
         self.set_current_match(match)
Пример #2
0
 def __event_bt_addplayer(self, checked):
     dialog = AddPlayerWindow(self)
     result = dialog.exec()
     if result:
         team = self.get_current_team()
         if dialog.get_lname() != "":
             player = model.getPlayerProvider().get_new(
                 team.id, dialog.get_lname(), dialog.get_fname())
         else:
             player = model.getPlayerProvider().get_randomplayer(team.id)
         dao.getPlayer().insert(player)
         self.__refresh_tab1()
         self.set_current_team(team)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 def __after_changed_property_current_team(self, team):
     self.__clear_listwidget(self.listWidget_playerslist)
     # get players for the team
     if team is not None:
         self.set_players(dao.getPlayer().getByTeam(team))
         self.pushButton_addplayer.setEnabled(True)
         self.pushButton_addplayer.setText("Add Player to {}".format(
             team.name))
     else:
         self.pushButton_addplayer.setEnabled(False)
Пример #7
0
 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)
Пример #8
0
    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)
Пример #9
0
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)
Пример #10
0
 def __event_bt_after_save_match(self):
     match = self.get_current_match()
     match.isplayed = True
     dao.getMatch().update(match)
     nextmatch = dao.getMatch().getNextMatch(self.get_competition())
     self.set_current_match(nextmatch)
Пример #11
0
 def __event_bt_deleteteam(self, checked):
     if dao.getTeam().delete(self.get_current_team()):
         self.__refresh_tab1()
Пример #12
0
 def __event_bt_deleteplayer(self, checked):
     if dao.getPlayer().delete(self.get_current_player()):
         self.set_current_player(None)
Пример #13
0
 def __update_result_after_match_finished(self):
     self.progressBar_competitionlevel.setValue(
         dao.getMatch().getMatchPlayed(self.get_competition()))
     matchs = dao.getMatch().getAll()
Пример #14
0
            self.teams[oteam1][1] += 1
            self.teams[oteam2][1] += 1
        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:
Пример #15
0
 def saveCalendar(cls, calendar):
     for i, t in enumerate(calendar):
         match = model.getMatchProvider().get_new(comment='match number {}'.format(i + 1))
         dao.getMatch().insert(match, t[0], t[1])