예제 #1
0
 def getMatchLine(self, match, teamId, leagueResLink):
     html = """
     <tr>
         <td class="date">{date}</td>
         <td class="time">{time}</td>
         <td class="court">{court}</td>
         <td class="opponent"><a href="{oppfix.url}">{oppname}</a></td>
         <td class="homeAway">{homeaway}</td>
         <td class="result">{result}</td>
     </tr>
     """
     mDate = DateFormatter.formatDate(match.datetime, False, False)
     mTime = DateFormatter.formatTime(match.datetime)
     mCourt = match.court
     mOppFixLink = PageLink("teamFixtures", self, {"team": match.opponentId}, True)
     mOppName = match.opponentName
     mHomeAway = "H" if match.home else "A"
     mOppId = match.opponentId
     mHomeId = teamId if match.home else mOppId
     mAwayId = mOppId if match.home else teamId 
     if match.result:
         if match.margin:
             res = "{0} by {1}".format(match.result, match.margin)
         else:
             res = "{0}".format(match.result)
         mResult = "<a href=\"{leaguefix.url}#{homeid}{awayid}\">{result}</a>".format(leaguefix=leagueResLink, teamid=teamId, homeid=mHomeId, awayid=mAwayId, result=res)
     else:
         mResult = ""
     answer = html.format(date=mDate, time=mTime, court=mCourt, oppfix = mOppFixLink, oppname=mOppName, homeaway=mHomeAway, result=mResult)
     return answer;
예제 #2
0
 def getMatchLine(self, match, prevTime):
     html = """
     <tr>
         <td class="time">{time}</td>
         <td class="court">{court}</td>
         <td class="teams">
             <a href="{homefix.url}">{homename}</a> 
             v
             <a href="{awayfix.url}">{awayname}</a>
         </td>
         {leaguefix}
     </tr>
     """
     mTime = DateFormatter.formatTime(match.time) if prevTime != match.time else ""
     mCourt = match.court
     mHomeFixLink = PageLink("teamFixtures", self, {"team": match.homeTeamId}, True)
     mHomeName = match.homeTeamName
     mAwayFixLink = PageLink("teamFixtures", self, {"team": match.awayTeamId}, True)
     mAwayName = match.awayTeamName
     mLeagueFix = ""
     if match.leagueId is not None:
         lfHtml = """
         <td>
             <a href="{leaguefix.url}">{leaguename}</a>
         </td>
         """
         lFixLink = PageLink("leagueFixtures", self, {"league": match.leagueId}, True)
         mLeagueFix = lfHtml.format(leaguefix=lFixLink, leaguename=match.leagueName)
     answer = html.format(time=mTime, court=mCourt, homefix = mHomeFixLink, homename=mHomeName, awayfix=mAwayFixLink, awayname=mAwayName, leaguefix=mLeagueFix)
     return answer;
예제 #3
0
 def getMatchLine(self, match, teamId, leagueResLink):
     html = """
     <tr>
         <td class="date">{date}</td>
         <td class="time">{time}</td>
         <td class="court">{court}</td>
         <td class="opponent"><a href="{oppfix.url}">{oppname}</a></td>
         <td class="homeAway">{homeaway}</td>
         <td class="result">{result}</td>
     </tr>
     """
     mDate = DateFormatter.formatDate(match.datetime, False, False)
     mTime = DateFormatter.formatTime(match.datetime)
     mCourt = match.court
     mOppFixLink = PageLink("teamFixtures", self,
                            {"team": match.opponentId}, True)
     mOppName = match.opponentName
     mHomeAway = "H" if match.home else "A"
     mOppId = match.opponentId
     mHomeId = teamId if match.home else mOppId
     mAwayId = mOppId if match.home else teamId
     if match.result:
         if match.margin:
             res = "{0} by {1}".format(match.result, match.margin)
         else:
             res = "{0}".format(match.result)
         mResult = "<a href=\"{leaguefix.url}#{homeid}{awayid}\">{result}</a>".format(
             leaguefix=leagueResLink,
             teamid=teamId,
             homeid=mHomeId,
             awayid=mAwayId,
             result=res)
     else:
         mResult = ""
     answer = html.format(date=mDate,
                          time=mTime,
                          court=mCourt,
                          oppfix=mOppFixLink,
                          oppname=mOppName,
                          homeaway=mHomeAway,
                          result=mResult)
     return answer
예제 #4
0
 def testFormatTimeDateTimePassed(self):
     time = datetime.datetime(2013, 7, 26, 12, 13)
     result = DateFormatter.formatTime(time)
     expectedResult = "12:13"
     self.assertEqual(expectedResult, result)
예제 #5
0
 def testFormatTimeTimePassed(self):
     time = datetime.time(14, 13)
     result = DateFormatter.formatTime(time)
     expectedResult = "2:13"
     self.assertEqual(expectedResult, result)