Ejemplo n.º 1
0
    def __html__(self):
        objL = []
        remainingFieldSet = set(self.config.fieldL)

        for i, date in enumerate(self.config.dateL):
            dateStr = 'date %d : %s' % (i + 1, date)
            objL.append(HtmlTag('h2', dateStr))

            d = {}
            count = 0
            for div in self.config.divL:
                for match in self.schDateDiv[(date, div)]:
                    count += 1
                    assert match.field.date is date

                    time = '%d:%02d' % unparseTime(match.field.time)
                    court = match.field.name
                    stadium = match.field.stadium

                    remainingFieldSet.remove(match.field)
                    if stadium not in d:
                        d[stadium] = {}
                    d[stadium][(
                        time, court
                    )] = '%s<font color="gray" size="-1" ><br> vs <br></font>%s' % (
                        match.team1.name, match.team2.name)

            for field in remainingFieldSet:
                if field.date is not date:
                    continue
                time = '%d:%02d' % unparseTime(field.time)
                if field.stadium not in d:
                    d[field.stadium] = {}
                d[field.stadium][(
                    time,
                    field.name)] = """<font color="gray" >AVAILABLE</font>"""

            for stadium, table in iteritems(d):
                objL.append(HtmlTag('h3', stadium))
                colL = TableMap(table).toStrMat()
                objL.append(
                    HtmlTable(list(zip(*colL)), [{
                        'align': 'center'
                    }] * len(colL),
                              border="1",
                              cellpadding="3",
                              cellspacing="0",
                              **{'class': 'table table-bordered'}))

        return '\n'.join([obj.__html__() for obj in objL])
Ejemplo n.º 2
0
    def __html__(self):
        objL = []
        remainingFieldSet = set(self.config.fieldL)

        for i, date in enumerate(self.config.dateL):
            dateStr = 'date %d : %s' % (i+1, date)
            objL.append(HtmlTag('h2', dateStr))

            d = {}
            count = 0
            for div in self.config.divL:
                for match in self.schDateDiv[(date, div)]:
                    count += 1
                    assert match.field.date is date

                    time = '%d:%02d' % unparseTime(match.field.time)
                    court = match.field.name
                    stadium = match.field.stadium

                    remainingFieldSet.remove(match.field)
                    if stadium not in d:
                        d[stadium] = {}
                    d[stadium][(time, court)] = '%s<font color="gray" size="-1" ><br> vs <br></font>%s' % (match.team1.name, match.team2.name)

            for field in remainingFieldSet:
                if field.date is not date:
                    continue
                time = '%d:%02d' % unparseTime(field.time)
                if field.stadium not in d:
                    d[field.stadium] = {}
                d[field.stadium][(time, field.name)] = """<font color="gray" >AVAILABLE</font>"""

            for stadium, table in iteritems(d):
                objL.append(HtmlTag('h3', stadium))
                colL = TableMap(table).toStrMat()
                objL.append(HtmlTable(list(zip(*colL)), [{'align': 'center'}]*len(colL), border="1", cellpadding="3", cellspacing="0", **{'class': 'table table-bordered'}))

        return '\n'.join([obj.__html__() for obj in objL])
Ejemplo n.º 3
0
 def __str__(self):
     h, m = unparseTime(self.time)
     return '%s-%s, %s %d:%02d' % (self.stadium, self.name, str(self.date), h, m)