Home | History | Annotate | Download | only in dashboard
      1 #!/usr/bin/env python
      2 #
      3 # Copyright (C) 2017 The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #      http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 #
     17 
     18 from webapp.src.handlers.base import BaseHandler
     19 from webapp.src.proto import model
     20 
     21 
     22 class SchedulePage(BaseHandler):
     23     """Main class for /schedule web page."""
     24 
     25     def get(self):
     26         """Generates an HTML page based on the task schedules kept in DB."""
     27         self.template = "schedule.html"
     28 
     29         schedule_query = model.ScheduleModel.query()
     30         schedules = schedule_query.fetch()
     31 
     32         if schedules:
     33             schedules = sorted(
     34                 schedules, key=lambda x: (x.manifest_branch, x.build_target),
     35                 reverse=False)
     36 
     37         template_values = {
     38             "schedules": schedules,
     39         }
     40 
     41         self.render(template_values)