Esempio n. 1
0
 def patternTimeTable(self, series, direction):
     table = markup.HTMLTable('timetable_%d' % direction, ['Station', 'A', 'V', 'meting', '#', 'delta', 'A', 'V'])
     indexes = range(len(series.points))
     if direction == Direction.down: indexes.reverse()
     for index in indexes:
         point = series.points[index]
         station = point.station
         planArrival, planDeparture = point.times_in_direction(direction)
         row = table.add_row()
         row.add_to_cell(0, station.name)
         row.add_to_cell(1, string_from_minutes(planArrival))
         row.add_to_cell(2, string_from_minutes(planDeparture))
         stationDict = self.results[direction].get(station.id, None)
         if stationDict == None:
             departure, count = ('-', '-')
             delta = 0
         else:
             departure, count = mostCommonItem(stationDict['v'])
             delta = departure - planDeparture
             departure = string_from_minutes(departure)
         row.add_to_cell(3, departure)
         row.add_to_cell(4, count)
         row.add_to_cell(5, delta)
         row.add_to_cell(6, markup.input('text', 'arr_%d_%d' % (direction, index), string_from_minutes(planArrival + delta), size=4))
         row.add_to_cell(7, markup.input('text', 'dep_%d_%d' % (direction, index), string_from_minutes(planDeparture + delta), size=4))
     return table
Esempio n. 2
0
    def overviewTable(self, missions):
        table = markup.HTMLTable('overview', ['Trein', 'Datum', 'Offset', 'Route', 'dV', 'Status'])
        for mission in missions:
            row = table.add_row()
            row.add_link_to_cell(0, '/console/schedule?mission=%s' % mission.id, mission.number)
            row.add_to_cell(1, mission.date_string)
            row.add_to_cell(2, mission.offset_string)
            if mission.stops:
                route = '%s - %s' % (mission.first_stop.station_id, mission.last_stop.station_id)
            else:
                route = '-'
            row.add_to_cell(3, route)

            (status, delay) = mission.status_at_time()
            row.add_to_cell(4, delay)
            row.add_to_cell(5, MissionStatuses.s[status])
        return table
Esempio n. 3
0
 def proposeChanges(self):
     table = markup.HTMLTable('submit_table', ['', 'Offset', 'Afronden'])
     form = markup.form('/tools/reoffset', 'post')
     form.add(markup.input('hidden', 'series', self.request.get('series')))
     form.add(table)
     self.doc.main.add(form)
     
     row = table.add_row()
     row.add_to_cell(0,'heen')
     row.add_to_cell(1, markup.input('text', 'offset_up', str(self.foundOffset[Direction.up]), size=6))
     row.add_to_cell(2, markup.input('text', 'round_up', '3', size=6))
     
     row = table.add_row()
     row.add_to_cell(0,'terug')
     row.add_to_cell(1, markup.input('text', 'offset_down', str(self.foundOffset[Direction.down]), size=6))
     row.add_to_cell(2, markup.input('text', 'round_down', '3', size=6))
     
     row = table.add_row()
     row.add_to_cell(0, markup.input('submit', value='pas aan'))
Esempio n. 4
0
 def add_table(self, name, columnTitles):
     table = markup.HTMLTable(name, columnTitles)
     self.main.add(table)
     return table
Esempio n. 5
0
    def get(self):
        kind = self.request.get('kind')
        if not self.series:
            self.response.out.write('Serie niet gevonden')
            return

        if kind == 'active':
            document = ConsoleDocument('Serie %s' % self.series.name)
            document.main.add(markup.heading(2, 'Heenrichting'))
            document.main.add(self.overviewTable(self.series.current_up_missions))
            document.main.add(markup.heading(2, 'Terugrichting'))
            document.main.add(self.overviewTable(self.series.current_down_missions))
            self.response.out.write(document.write())

        if kind == 'all':
            document = ConsoleDocument('Serie %s' % self.series.name)
            document.main.add(markup.heading(2, 'Heenrichting'))
            document.main.add(self.overviewTable(self.series.up_missions))
            document.main.add(markup.heading(2, 'Terugrichting'))
            document.main.add(self.overviewTable(self.series.down_missions))
            self.response.out.write(document.write())

        elif kind == 'pattern':
            direction = self.request.get('direction')
            up = direction != 'down'
            if up:
                label = 'heen'
                reverse = 'down'
                reverse_label = 'toon terugrichting'
                origin = self.series.first_point.stationName
                destination = self.series.last_point.stationName
                missions = self.series.up_missions
            else:
                label = 'terug'
                reverse = 'up'
                reverse_label = 'toon heenrichting'
                origin = self.series.last_point.stationName
                destination = self.series.first_point.stationName
                missions = self.series.down_missions

            document = ConsoleDocument('Serie %s (%s)' % (self.series.name, label))
            changes = self.request.get('changes')
            if changes: document.add_paragraph('%s missies zijn aangepast.' % changes)
            document.add_paragraph('%d treinen in serie %s %s - %s' % (self.series.nr_of_missions, self.series.name, origin, destination))
            document.add_reference('/console/missions?kind=pattern&series=%s&direction=%s' % (self.series.id, reverse),reverse_label)

            url = '/TASeries/%s' % self.series.id
            form1 = markup.form(url, 'post')
            form1.add(markup.input('hidden', 'inst', 'optimize_odids'))
            form1.add(markup.input('submit', value='Optimaliseer waarden'))
            document.main.add(form1)

            form2 = markup.form('/forms/series', 'post')
            form2.add(markup.input('hidden', 'series', self.series.id))
            form2.add(markup.input('hidden', 'direction', self.request.get('direction')))
            table = markup.HTMLTable('missions_table', ['Trein', 'Offset', 'Bediende traject'])
            form2.add(table)
            form2.add(markup.input('submit', value='Wijzigen'))
            document.main.add(form2)
            for mission in missions:
                row = table.add_row()
                row.add_to_cell(0, mission.number)
                row.add_to_cell(1, markup.input('text', 'offset_%d' % mission.number, mission.offset_string, size=6))
                name = 'odids_%d' % mission.number
                array = []
                for key, value in mission.odIDs_dictionary.iteritems():
                    array.append((key, value))
                array.sort()
                odids = []
                for key, value in array:
                    odids.append('%s: %s-%s' % (dayString(key), value[0], value[1]))
                row.add_to_cell(2, markup.input('text', name, ', '.join(odids), size=75))
            self.response.out.write(document.write())
Esempio n. 6
0
 def add_table(self, name, columnTitles, format=None):
     table = markup.HTMLTable(name, columnTitles)
     if format != None: table.format = format
     self.main.add(table)
     return table